crypto
native moduleHash digests + a CSPRNG. import "crypto". Digests return lowercase hex. Broader crypto (AEAD, signatures, KDFs) is intentionally left to an extension.
crypto.sha256(s: string) => stringcrypto.sha512(s: string) => stringcrypto.sha1(s: string) => stringcrypto.md5(s: string) => stringcrypto.hmac_sha256(key, msg: string) => stringcrypto.secure_random(n: int) => stringcrypto.constant_time_eq(a, b: string) => bool
crypto.sha256(s: string) => string
SHA-256 hex digest.
crypto.sha512(s: string) => string
SHA-512 hex digest.
crypto.sha1(s: string) => string
SHA-1 hex (LEGACY/insecure; interop only).
crypto.md5(s: string) => string
MD5 hex (LEGACY/insecure; interop only).
crypto.hmac_sha256(key, msg: string) => string
HMAC-SHA256 tag as hex.
crypto.secure_random(n: int) => string
n cryptographically-secure random bytes.
crypto.constant_time_eq(a, b: string) => bool
Compare two strings (e.g. hex digests/MACs) in constant time, without leaking where they first differ.