Skip to content

Hash

mash.hash · Utilities

hash.equals(known: mixed, supplied: mixed) → bool

Compare a known value (such as a signature you computed) with a supplied one in constant time. Use it to check webhook signatures rather than == or ===. Both must be encoded the same way (hex with hex, base64 with base64). Anything that is not a string, such as a missing header, is never equal.

hash.hmac(algo: string, data: string, key: string, binary?: bool = false) → string

Generate a keyed HMAC hash.

hash.md5(value: string) → string

Generate an MD5 hash.

hash.murmur(value: string, seed?: int = 0) → string

Generate a Murmur3 hash.

hash.murmurInt(value: string, seed?: int = 0) → int

Generate a Murmur3 hash as an integer.

hash.password(value: string) → string

Hash a password using bcrypt.

hash.sha256(value: string) → string

Generate a SHA-256 hash.

hash.sha512(value: string) → string

Generate a SHA-512 hash.

hash.verifyPassword(password: string, hash: string) → bool

Verify a password against a hash.