Binary and streaming hashes

hash.md5Bytes(byte[]), hash.sha1Bytes(byte[]), and hash.sha256Bytes(byte[]) include every byte, including NUL. Digests are lowercase hexadecimal strings.

HashState state = hash.begin("sha256")
byte[] mapped = fs.mapBytesSync("weights.gguf")
hash.update(state, mapped, 0, mapped.length64())
string digest = hash.hexDigest(state)

hash.begin(algorithm) accepts exactly md5, sha1, sha256, or sha512; unknown algorithms throw. MD5 and SHA-1 are provided for compatibility checksums, not security-sensitive collision resistance.

hash.update(state, bytes, offset, count) processes a byte range synchronously. Offsets and counts accept long integers; negative values, overflowed ranges, and ranges outside the input throw before changing the state. A zero-length range at the end is valid. Full blocks are read directly from the input, so mapped ranges need no intermediate slice or whole-file allocation. Only a partial block (at most 127 bytes) is retained. Input storage is not retained and may be released or changed after the call returns.

hash.hexDigest(state) is a snapshot: it does not consume or reset the state. Repeated calls give the same digest until another update; updates can continue after a digest. States use managed arena storage and require no explicit close. Assignment aliases the mutable state within its lifetime; do not concurrently update the same state from multiple threads.

The existing string hash APIs and SHA-256 raw core also use bounded-memory streaming internally. State memory is constant regardless of input size.

Native differential validation: python3 tests/runners/hash-streaming.py. Compiler integration: radlang rtest tests/regression/tests/language/hash-streaming.test.rad.