IF Commons GitHub

md5

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-crypto FR-002

MD5 (RFC 1321), which Web Crypto does not give, for the protocols that still ask for it: S3's Content-MD5 header (the digest in base64), the ETag of an S3 object put in one part, and old checksum files (commons 0001-crypto FR-002).

MD5 is NOT for security: collisions are made in seconds, so it MUST NOT check that bytes are the ones expected against anyone who could choose them, sign, or hash a password. Use SHA-256 (./sha256.ts) for that; MD5 here only answers a protocol that names it.

The digest is given whole (md5, md5Hex) or a piece at a time (Md5, and md5Stream for a ReadableStream), so a file larger than memory is digested as it is read.

import { Md5, md5Hex } from "./md5.ts";
md5Hex("abc"); // "900150983cd24fb0d6963f7d28e17f72"
new Md5().update("a").update("bc").hex(); // the same

Source: commons/crypto/src/md5.ts

7 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

md5namespace
namespace md5
md5.Md5class
class Md5

An MD5 digest computed a piece at a time: update with each piece of the bytes in order (text is taken as UTF-8), then digest or hex. After the digest is taken, the object takes no more bytes. Not for security (see the module's documentation).

MemberTypeWhat it is
update(data: string | Uint8Array<ArrayBufferLike>) => Md5Takes the next piece of the bytes; throws where the digest was already taken.
digest() => Uint8Array<ArrayBufferLike>The 16 bytes of the digest of every piece taken; the same each time it is asked.
hex() => stringThe digest as 32 lower-case hexadecimal digits.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

md5.md5function
function md5(data: string | Uint8Array<ArrayBufferLike>): Uint8Array<ArrayBufferLike>

The 16 bytes of the MD5 of bytes, or of text as UTF-8. Not for security.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

md5.md5Hexfunction
function md5Hex(data: string | Uint8Array<ArrayBufferLike>): string

The MD5 of bytes, or of text as UTF-8, as 32 lower-case hexadecimal digits (md5("") is d41d8cd98f00b204e9800998ecf8427e).

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

md5.md5Streamfunction
function md5Stream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): Promise<Uint8Array<ArrayBufferLike>>

The 16 bytes of the MD5 of every byte of a stream, read a chunk at a time, so the whole is never held. Not for security.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

Md5class
class Md5

An MD5 digest computed a piece at a time: update with each piece of the bytes in order (text is taken as UTF-8), then digest or hex. After the digest is taken, the object takes no more bytes. Not for security (see the module's documentation).

MemberTypeWhat it is
update(data: string | Uint8Array<ArrayBufferLike>) => Md5Takes the next piece of the bytes; throws where the digest was already taken.
digest() => Uint8Array<ArrayBufferLike>The 16 bytes of the digest of every piece taken; the same each time it is asked.
hex() => stringThe digest as 32 lower-case hexadecimal digits.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

md5Hexfunction
function md5Hex(data: string | Uint8Array<ArrayBufferLike>): string

The MD5 of bytes, or of text as UTF-8, as 32 lower-case hexadecimal digits (md5("") is d41d8cd98f00b204e9800998ecf8427e).

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

md5Streamfunction
function md5Stream(stream: ReadableStream<Uint8Array<ArrayBufferLike>>): Promise<Uint8Array<ArrayBufferLike>>

The 16 bytes of the MD5 of every byte of a stream, read a chunk at a time, so the whole is never held. Not for security.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.