Digest.BLAKE256(3)
π Digest.BLAKE256 β the Digest.BLAKE256(3) page, bestie edition
okay so you opened section 3 of the OCaml library manual, and it's the Digest.BLAKE256 page, and honestly? it's a slay. let's get into it β¨
β¨ NAME β¨
Digest.BLAKE256 β BLAKE256 is the BLAKE2b hash function producing 256-bit (32-byte) digests. that's the whole vibe. π
π¦ Module π¦
Module Digest.BLAKE256
πΈ Documentation πΈ
Module BLAKE256 : S
no cap, this module is an S. signature match, periodt. π
BLAKE256 is the BLAKE2b hash function producing 256-bit (32-byte) digests. It is cryptographically secure, and the digests are large enough to thwart brute-force attacks. so likeβ¦ it's giving security, it's giving strength, it's giving "your data is safe bestie." π₯
Since 5.2 β yeah she's new-ish, but she's iconic. π
the type π§
type t = string
The type of digests. it's literally just a string. that's it. that's the type. lowkey humble of her. π
val hash_length : int
The length of digests, in bytes. it's an int, it's a length, it's in bytes. use it, don't guess it. β¨
val compare : t -> t -> int
Compare two digests, with the same specification as compare. so it does the comparison thing the way compare does the comparison thing. iykyk. π«Ά
val equal : t -> t -> bool
Test two digests for equality. are they the same? true. are they not? false. the vibe check of functions, honestly. π
val string : string -> t
Return the digest of the given string. hand her a string, she hands you back a digest. that's the transaction. π«
val bytes : bytes -> t
Return the digest of the given byte sequence. same energy, but for bytes instead of string. π
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. so you're like "here's a string, here's where to start, here's how much to take" and she digests just that part. queen of boundaries. π
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. same deal as substring but the input is bytes and we're counting bytes. π
val channel : in_channel -> int -> t
Read characters from the channel and return their digest. See Digest.channel for the full specification. yes bestie, go read that one too β the full spec lives over there, this is the pointer. π
val file : string -> t
Return the digest of the file whose name is given. point her at a filename, get a digest. very main character of you, very main character of her. π₯
val output : out_channel -> t -> unit
Write a digest on the given output channel. returns unit, so don't go looking for a return value, she's just out here writing. π
val input : in_channel -> t
Read a digest from the given input channel. the reverse of output β she reads it back and hands you a t. π¦
val to_hex : t -> string
Return the printable hexadecimal representation of the given digest. so your blob of digest becomes nice readable hex characters. obsessed. β¨
careful bestie β RaisesInvalid_argumentif the length of the argument is nothash_length. so fr fr, check your lengths before you @ her. π
val of_hex : string -> t
Convert a hexadecimal representation back into the corresponding digest. hex in, digest out. the glow-up reversal. πΈ
also careful β RaisesInvalid_argumentif the length of the argument is not2 * hash_length, or if the argument contains non-hexadecimal characters. do the math, keep it valid, and please don't sneak in a"z". π
π cute sign-off π
that's the whole page! this lil doc came from OCamldoc, dated 2026-06-22, and it's living on the Digest.BLAKE256(3) manual page β go forth, hash responsibly, and stan BLAKE2b. π
β¨π«Ά
π¦ 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