Encoding & cryptographyReference
crypt.hash
Calculate a hexadecimal digest of local bytes.
Details#
Calculate a hexadecimal digest of local bytes. Lowercase hexadecimal digest. An unsupported algorithm or hashing failure raises an error.
Signature#
crypt.hash(data: string, algorithm: string?): stringParameters#
| Parameter | Type | Description |
|---|---|---|
data | string | Raw bytes to hash. |
algorithmoptional | string | Default sha384. Accepts md5, sha1, sha224, sha256, sha384, sha512 and sha3-224/256/384/512; SHA-3 also accepts an underscore instead of the hyphen. Names are case-insensitive. |
Returns#
Lowercase hexadecimal digest. An unsupported algorithm or hashing failure raises an error.
Examples#
Local example
print(crypt.hash("hello", "sha256"))
-- 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824