Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.82 KB

hash.md

File metadata and controls

54 lines (36 loc) · 1.82 KB
id stdlib-hash
title Hash Module
slug /stdlib/hash

Hosted interpreter permissions: Every function and value on this page requires no host permissions. Higher-order functions still enforce the requirements of their callbacks. These checks do not apply to CLI execution or compilation. See Host permissions.

Hash is provided by the default .NET runtime extern registry.

Hash.md5 : string -> string option

None

Hashes the UTF-8 bytes of the input and returns a lowercase, 32-character hexadecimal digest. Returns None if hashing fails.

let digest = Hash.md5 "hello"
// Some "5d41402abc4b2a76b9719d911017c592"

Use this for compatibility checks or non-security fingerprints. MD5 is unsuitable for password storage or security-sensitive integrity checks.

Pure support additions

Hash.sha256

None

Hash.sha256 : string -> string option

Returns a lowercase SHA-256 digest of the supplied text’s strict UTF-8 bytes, without a BOM. Invalid UTF-16 returns None.

Hash.sha256 "abc"
// Some "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"

Hash.sha256Bytes

None

Hash.sha256Bytes : int list -> string option

Returns a lowercase SHA-256 digest of supplied bytes. Invalid byte values return None.

Hash.sha256Bytes [97;98;99]
// Some "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"