Digest.BLAKE128(3)

πŸ’– Digest.BLAKE128 β€” the OCaml library page, but make it make sense πŸ’–

okay so bestie, welcome to Digest.BLAKE128 from the OCaml library (Digest.BLAKE128(3), section 3, iykyk). this whole page is literally about one little module and it's lowkey iconic, let's go 🫢


✨ NAME ✨

Digest.BLAKE128 β€” BLAKE128 is the BLAKE2b hash function producing 128-bit (16-byte) digests. no cap, that's the whole vibe of the page πŸŽ€


πŸ¦‹ Module πŸ¦‹

Module Digest.BLAKE128


🌸 Documentation 🌸

Module BLAKE128 : S

ok so BLAKE128 is the BLAKE2b hash function producing 128-bit (16-byte) digests. it is cryptographically secure β€” slay β€” BUT (and this is the important part, bestie, don't skip it) the small size of the digests enables brute-force attacks in 2{^64} attempts. so like, secure, but the tiny digest size is giving "crackable with enough brute force" energy πŸ’€

Since 5.2


πŸ’… the types and values πŸ’…

  • type t = string β€” the type of digests. that's it, that's the type. a digest is literally a string around here ✨
  • val hash_length : int β€” the length of digests, in bytes. this number matters later, remember it 🧚
  • val compare : t -> t -> int β€” compare two digests, with the same specification as compare. (yes, that compare, the one you already know and love.)
  • val equal : t -> t -> bool β€” test two digests for equality. simple. clean. iconic.
  • val string : string -> t β€” return the digest of the given string. feed it a string, get a digest back πŸ“
  • val bytes : bytes -> t β€” return the digest of the given byte sequence. same deal but with bytes.
  • val substring : string -> int -> int -> t β€” substring s ofs len returns the digest of the substring of s starting at index ofs and containing len characters. yes, characters, not bytes, because it's a string.
  • val subbytes : bytes -> int -> int -> t β€” subbytes s ofs len returns the digest of the subsequence of s starting at index ofs and containing len bytes. this one's the bytes twin, and it counts bytes, okay? don't mix them up 🫢
val substring : string -> int -> int -> t
val subbytes : bytes -> int -> int -> t
  • val channel : in_channel -> int -> t β€” read characters from the channel and return their digest. for the full specification, go look at Digest.channel β€” it's the main character, this one's just the BLAKE128 version of it πŸ’œ
  • val file : string -> t β€” return the digest of the file whose name is given. just hand it a filename, that's the whole thing.
  • val output : out_channel -> t -> unit β€” write a digest on the given output channel.
  • val input : in_channel -> t β€” read a digest from the given input channel. (see how it's the mirror of output? obsessed with the symmetry honestly)
  • val to_hex : t -> string β€” return the printable hexadecimal representation of the given digest. so your digest becomes a cute lil readable hex string ✨
raises Invalid_argument if the length of the argument is not hash_length. note that trailing comma in the original, it's part of the lore lmaoo 😭
  • val of_hex : string -> t β€” convert a hexadecimal representation back into the corresponding digest. the reverse trip, we love a round-trip πŸŽ€
raises Invalid_argument if the length of the argument is not 2 * hash_length, or if the arguments contains non-hexadecimal characters. so like β€” wrong length or wrong characters and it's a no from it πŸ™ˆ
val to_hex : t -> string
val of_hex : string -> t

that's genuinely every single value on the page, bestie, nothing skipped, nothing invented, we ate and left no crumbs πŸ‘‘


✨ cute lil sign-off ✨

this page was brought to you by OCamldoc, dated 2026-06-22 β€” that's the source/version and the date, right at the bottom where the footer always lives. go forth and hash responsibly, 128 bits at a time πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from