std/sha512
Pure-Milo SHA-512 and SHA-384 (FIPS 180-4), no platform crypto dependency.
from "std/sha512" import { Sha512, Sha384 }The same shape as std/sha256, one size up: 64-bit lanes, a 128-byte block, 80 rounds, and a 128-bit length field. SHA-384 is the identical compression function with a different initial state, truncated to 48 bytes — the truncation is what makes it resistant to the length-extension attack SHA-512 admits.
Every branch and memory access is on public data (round index, message length), so the trace is input-independent.
Checked against the FIPS 180-4 / RFC 6234 vectors in tests/fixtures/sha512Vectors.milo.
API reference
Sha384
pub struct Sha384Sha384 namespace — SHA-512 truncated to 48 bytes with a different initial state.
Sha384.bytes
fn Sha384.bytes(input: &string): stringRaw 48-byte SHA-384 digest.
Sha384.hash
fn Sha384.hash(input: &string): string48-byte SHA-384 digest as 96-char lowercase hex.
Sha512
pub struct Sha512Sha512 namespace — Sha512.hash(input) 128-char hex, Sha512.bytes(input) 64 raw bytes.
Sha512.bytes
fn Sha512.bytes(input: &string): stringRaw 64-byte SHA-512 digest. Use this when the digest feeds further bytes (HMAC, key derivation) rather than a display string.
Sha512.hash
fn Sha512.hash(input: &string): string64-byte SHA-512 digest as 128-char lowercase hex.