Funções de Hash
Funções de Hash
Seção intitulada “Funções de Hash”Funções de hash criptograficas e autenticação de mensagens HMAC.
Carregamento
Seção intitulada “Carregamento”local hash = require("hash")Hashes Criptograficos
Seção intitulada “Hashes Criptograficos”local hex = hash.md5("data")local raw = hash.md5("data", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Dados para hash |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
local hex = hash.sha1("data")local raw = hash.sha1("data", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Dados para hash |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
SHA-256
Seção intitulada “SHA-256”local hex = hash.sha256("data")local raw = hash.sha256("data", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Dados para hash |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
SHA-512
Seção intitulada “SHA-512”local hex = hash.sha512("data")local raw = hash.sha512("data", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Dados para hash |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
Autenticação HMAC
Seção intitulada “Autenticação HMAC”HMAC-MD5
Seção intitulada “HMAC-MD5”local hex = hash.hmac_md5("message", "secret")local raw = hash.hmac_md5("message", "secret", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Mensagem para autenticar |
secret | string | Chave secreta |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
HMAC-SHA1
Seção intitulada “HMAC-SHA1”local hex = hash.hmac_sha1("message", "secret")local raw = hash.hmac_sha1("message", "secret", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Mensagem para autenticar |
secret | string | Chave secreta |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
HMAC-SHA256
Seção intitulada “HMAC-SHA256”local hex = hash.hmac_sha256("message", "secret")local raw = hash.hmac_sha256("message", "secret", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Mensagem para autenticar |
secret | string | Chave secreta |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
HMAC-SHA512
Seção intitulada “HMAC-SHA512”local hex = hash.hmac_sha512("message", "secret")local raw = hash.hmac_sha512("message", "secret", true)| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Mensagem para autenticar |
secret | string | Chave secreta |
raw | boolean? | Retornar bytes raw ao inves de hex |
Retorna: string, error
Hashes Não-Criptograficos
Seção intitulada “Hashes Não-Criptograficos”Hash rapido para hash tables e particionamento.
local n = hash.fnv32("data")| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Dados para hash |
Retorna: number, error
Hash rapido com saida maior para menos colisoes.
local n = hash.fnv64("data")| Parâmetro | Tipo | Descrição |
|---|---|---|
data | string | Dados para hash |
Retorna: number, error
| Condição | Tipo | Retentável |
|---|---|---|
| Input não e string | errors.INVALID | não |
| Secret não e string (HMAC) | errors.INVALID | não |
Veja Error Handling para trabalhar com erros.