hash
Shared
Hashes a text: MD5, SHA-1, SHA-2 or an HMAC.
string|false hash(string algorithm, string data [, table options = nil])
Parameters
| Name | Type | Description |
|---|---|---|
| algorithm | string | "md5", "sha1", "sha224", "sha256", "sha384", "sha512" or "hmac". |
| data | string | The text. |
| options | table | Only for "hmac": key (the key) and algorithm (one of the other algorithms).default nil |
Returns
The hash in lowercase hex, or false if the HMAC options are invalid.
Example
local digest = hash("sha256", "hello")
local signature = hash("hmac", "payload", { key = "secret", algorithm = "sha256" })