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 β€” Raises Invalid_argument if the length of the argument is not hash_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 β€” Raises Invalid_argument if the length of the argument is not 2 * 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