Hash
mash.hash · Utilities
Methods
Section titled “Methods”equals
Section titled “equals”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.
murmur
Section titled “murmur”hash.murmur(value: string, seed?: int = 0) → string
Generate a Murmur3 hash.
murmurInt
Section titled “murmurInt”hash.murmurInt(value: string, seed?: int = 0) → int
Generate a Murmur3 hash as an integer.
password
Section titled “password”hash.password(value: string) → string
Hash a password using bcrypt.
sha256
Section titled “sha256”hash.sha256(value: string) → string
Generate a SHA-256 hash.
sha512
Section titled “sha512”hash.sha512(value: string) → string
Generate a SHA-512 hash.
verifyPassword
Section titled “verifyPassword”hash.verifyPassword(password: string, hash: string) → bool
Verify a password against a hash.