Digest.MD5(3)
π Digest.MD5(3) π
Ok bestie, welcome to the Digest.MD5(3) page from the OCaml library β we're talking about the Digest.MD5 module, and yes, it's giving very specific hash-function energy. Let's get into it π
β¨ NAME β¨
Digest.MD5 β MD5 is the MD5 hash function. No cap, that's literally the name and the job πΈ
π§© Module π§©
- Module:
Digest.MD5β that's the module we're living in, bestie π«Ά
π Documentation π
- Module
MD5:Sβ the signature situation, exactly as written.
MD5 is the MD5 hash function. It produces 128-bit (16-byte) digests, and it is not cryptographically secure at all. Like, do not use it for security, fr fr π It should be used only for compatibility with earlier designs that mandate the use of MD5. That's the whole vibe: legacy compatibility, not main character security energy π
β¨ Since 5.2 β¨
type t = stringβ the type of digests. That's the digest representation right there πval hash_length : intβ the length of digests, in bytes. Short, sweet, and exactly what it says πval compare : t -> t -> intβ compare two digests, with the same specification ascompare. Bestie, it's the comparison behavior you already know and love πval equal : t -> t -> boolβ test two digests for equality. Simple vibe check: equal or not equal π¦val string : string -> tβ return the digest of the given string. String goes in, digest comes out β¨val bytes : bytes -> tβ return the digest of the given byte sequence. Byte-sequence bestie gets the same treatment πval substring : string -> int -> int -> tβsubstring s ofs lenreturns the digest of the substring ofsstarting at indexofsand containinglencharacters. Slice that string, hash that slice, periodt πval subbytes : bytes -> int -> int -> tβsubbytes s ofs lenreturns the digest of the subsequence ofsstarting at indexofsand containinglenbytes. Same idea, but the byte-sequence edition π§val channel : in_channel -> int -> tβ read characters from the channel and return their digest. SeeDigest.channelfor the full specification. Go check that one for the whole story, iykyk πval file : string -> tβ return the digest of the file whose name is given. Give it a filename, get a digest πval output : out_channel -> t -> unitβ write a digest on the given output channel. Digest goes out through the channel, slay πval input : in_channel -> tβ read a digest from the given input channel. Digest comes in from the channel, iconic π¦val to_hex : t -> stringβ return the printable hexadecimal representation of the given digest. Hex string era β¨
Raises Invalid_argument if the length of the argument is not hash_length, π
val of_hex : string -> tβ convert a hexadecimal representation back into the corresponding digest. Hex string goes back to digest form, no cap π
Raises Invalid_argument if the length of the argument is not 2 * hash_length, or if the arguments contains non-hexadecimal characters. That's the guardrail, bestie π§
Cute sign-off time π«Ά: this little page came from OCamldoc, dated 2026-06-22, and it's the Digest.MD5(3) manual page. Bye bestie, stay hashing responsibly πβ¨
π¦ 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