module

Hwaro::Utils::DigestUtils

Instance methods

sri(data : String | Bytes) : String

Subresource Integrity value (sha384-<base64>) of data.

Source
sri_file(path : String) : String | Nil

sri of a file's bytes, or nil when it is not a readable file.

Source
update_length_prefixed(digest : Digest, value : String) : Nil

Fold value into digest with a length prefix so adjacent fields can't produce identical byte streams across boundaries (the "a"+"bc" vs "ab"+"c" ambiguity, which would make two different inputs hash identically and silently fail to invalidate a cache). One implementation for every fingerprint site — template/config checksums, the data-directory digest, and cascade fingerprints — so the prefixing scheme can't drift between cache layers.

Source