std::sha1

std/src/sha1.mo

SHA-1 (FIPS 180-4).

Public API: Sha1.hash : String -> String (lowercase 40-hex-char digest) and Sha1.hash_bytes : List U8 -> List U8 (raw 20-byte digest).

SHA-1 is broken for collision resistance. It is here because protocols still name it — the WebSocket handshake's Sec-WebSocket-Accept (RFC 6455 §4.2.2) is the reason it exists — never for integrity or authentication. Use std::sha256 for anything security-relevant.

The byte packing, padding and block splitting are SHA-256's (the two share the 512-bit block, the big-endian word order and the length footer, including its under-2^32-bits assumption); only the schedule and the compression rounds differ.

instance_#
pub instance Copy Sha1State {
    def copy (s : Sha1State) : Pair Sha1State Sha1State := Pair.pair s s
}

Five 32-bit registers; duplicating the state is a register copy.

defSha1.hash_bytes#
pub def Sha1.hash_bytes (bytes : List U8) : List U8

The raw 20-byte digest.

defSha1.hash#
pub def Sha1.hash (s : String) : String

The lowercase hex digest of a string's UTF-8 bytes.