hash
Compartilhado
Calcula o hash de um texto: MD5, SHA-1, SHA-2 ou um HMAC.
string|false hash(string algorithm, string data [, table options = nil])
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
| algorithm | string | "md5", "sha1", "sha224", "sha256", "sha384", "sha512" ou "hmac". |
| data | string | O texto. |
| options | table | Só para "hmac": key (a chave) e algorithm (um dos outros algoritmos).padrão nil |
Retorno
O hash em hexadecimal minúsculo, ou false se as opções do HMAC são inválidas.
Exemplo
local digest = hash("sha256", "hello")
local signature = hash("hmac", "payload", { key = "secret", algorithm = "sha256" })