std.sha256
SHA-256, the hash of FIPS 180-4: any bytes to 32 bytes, so that bytes that are not the same are, as far as anyone can find, not hashed to the same 32. Written in heff, a block of 64 bytes at a time.
import bytes as Bytesimport std.sha256 as SHA256
-- | whether a file's content is what its published hash saysintact : Bytes -> Bytes -> Boolintact content published = SHA256.digest content == publisheddigest
digest : Bytes -> BytesThe SHA-256 hash of the bytes, 32 bytes.
>>> digest Bytes.empty == b[0xe3b0c44298fc1c14::64, 0x9afbf4c8996fb924::64, 0x27ae41e4649b934c::64, 0xa495991b7852b855::64]True>>> digest (Bytes.fromString "abc") == b[0xba7816bf8f01cfea::64, 0x414140de5dae2223::64, 0xb00361a396177a9c::64, 0xb410ff61f20015ad::64]True>>> digest (Bytes.fromString "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") == b[0x248d6a61d20638b8::64, 0xe5c026930c3e6039::64, 0xa33ce45964ff2167::64, 0xf6ecedd419db06c1::64]True>>> digest (Bytes.fromString "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu") == b[0xcf5b16a778af8380::64, 0x036ce59e7b049237::64, 0x0b249b11e8f07a51::64, 0xafac45037afee9d1::64]True>>> digest (Bytes.fromList (List.replicate 1000 97)) == b[0x41edece42d63e8d9::64, 0xbf515a9ba6932e1c::64, 0x20cbc9f5a5d13464::64, 0x5adb5db1b9737ea3::64]True