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 ascompare. (yes, thatcompare, 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 withbytes.val substring : string -> int -> int -> tβsubstring s ofs lenreturns the digest of the substring ofsstarting at indexofsand containinglencharacters. yes, characters, not bytes, because it's astring.val subbytes : bytes -> int -> int -> tβsubbytes s ofs lenreturns the digest of the subsequence ofsstarting at indexofsand containinglenbytes. this one's thebytestwin, 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 atDigest.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 ofoutput? 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 β¨
raisesInvalid_argumentif the length of the argument is nothash_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 π
raisesInvalid_argumentif the length of the argument is not2 * 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
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms