Digest.S(3)

πŸ’– NAME πŸ’–

okay bestie, welcome to Digest.S(3) from the OCaml library manual β€” literally the signature page for a hash function that produces digests of length hash_length from character strings, byte arrays, and files. It's giving cryptographic main character energy πŸ’…βœ¨

🧚 Module type 🧚

Module type Digest.S β€” yes, that's the module type, no cap. 🫢

🌸 Documentation 🌸

Module type S
 = sig end

The signature for a hash function that produces digests of length hash_length from character strings, byte arrays, and files. Since 5.2 β€” iconic, we love a recent-era vibe. πŸŽ€

  • type t = string β€” the type of digests. Literally just a string, bestie. Slay. πŸ’–
  • val hash_length : int β€” the length of digests, in bytes. No cap, that's the size vibe. ✨
  • val compare : t -> t -> int β€” compare two digests, with the same specification as compare. Same spec energy, fr fr. πŸ¦‹
  • val equal : t -> t -> bool β€” test two digests for equality. Vibe check: are they equal or not? 😭
  • val string : string -> t β€” return the digest of the given string. String in, digest out, periodt. πŸ’…
  • val bytes : bytes -> t β€” return the digest of the given byte sequence. Byte sequence bestie, you know the drill. 🌸
  • 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. Precision slicing, we love to see it. πŸŽ€
  • 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. Bytes edition, same iconic energy. πŸ¦‹
  • val channel : in_channel -> int -> t β€” read characters from the channel and return their digest. See Digest.channel for the full specification. Go read Digest.channel if you want the whole lore. πŸ‘‘
  • val file : string -> t β€” return the digest of the file whose name is given. File name goes in, digest comes out. πŸ“
  • val output : out_channel -> t -> unit β€” write a digest on the given output channel. Output channel said: put that digest here. πŸ’œ
  • val input : in_channel -> t β€” read a digest from the given input channel. Input channel said: here's your digest. ✨
  • val to_hex : t -> string β€” return the printable hexadecimal representation of the given digest. Raises Invalid_argument if the length of the argument is not hash_length, and that's the whole rule. 😭
  • val of_hex : string -> t β€” convert a hexadecimal representation back into the corresponding digest. Raises Invalid_argument if the length of the argument is not 2 * hash_length, or if the arguments contains non-hexadecimal characters. Hex in, digest out β€” but only if the vibe check passes. πŸ”₯

okay that's the whole page, bestie! this little beauty was brought to you by OCamldoc, dated 2026-06-22, and it's literally Digest.S(3) β€” byeee 🫢✨

πŸ“¦ where this page comes from