Syntax
crypt.hash(data: string, algorithm?: "sha256" | "sha1" | "sha224" | "sha384" | "sha512" | "md5" | "sha3-224" | "sha3-256" | "sha3-384" | "sha3-512"): stringArguments
| Name | Type | Description |
|---|---|---|
data | string | Lua string bytes passed to crypto library HashFilter. |
algorithm? | "sha256" | "sha1" | "sha224" | "sha384" | "sha512" | "md5" | "sha3-224" | "sha3-256" | "sha3-384" | "sha3-512" | Case-sensitive hash algorithm name. Defaults to sha256. |
Returns
| Name | Type | Description |
|---|---|---|
digest | string | Lowercase hexadecimal digest with no prefix or separators. |
Description
Hashes Lua string bytes with a supported crypto library hash algorithm and returns a lowercase hexadecimal digest.
Call it with 2 parameter(s): data, algorithm. The argument table explains which values are required and which ones only refine the behavior.
It returns digest (string). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Hash Lua string bytes with the default algorithm or an explicit supported name.
local defaultDigest = crypt.hash("hello world")
local sha3Digest = crypt.hash("hello world", "sha3-256")
print(defaultDigest)
print(sha3Digest)