Funciones Hash
Funciones Hash
Sección titulada «Funciones Hash»Funciones hash criptograficas y autenticación de mensajes HMAC.
local hash = require("hash")Hashes Criptograficos
Sección titulada «Hashes Criptograficos»local hex = hash.md5("data")local raw = hash.md5("data", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Datos a hashear |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
local hex = hash.sha1("data")local raw = hash.sha1("data", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Datos a hashear |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
SHA-256
Sección titulada «SHA-256»local hex = hash.sha256("data")local raw = hash.sha256("data", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Datos a hashear |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
SHA-512
Sección titulada «SHA-512»local hex = hash.sha512("data")local raw = hash.sha512("data", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Datos a hashear |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
Autenticación HMAC
Sección titulada «Autenticación HMAC»HMAC-MD5
Sección titulada «HMAC-MD5»local hex = hash.hmac_md5("message", "secret")local raw = hash.hmac_md5("message", "secret", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Mensaje a autenticar |
secret | string | Clave secreta |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
HMAC-SHA1
Sección titulada «HMAC-SHA1»local hex = hash.hmac_sha1("message", "secret")local raw = hash.hmac_sha1("message", "secret", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Mensaje a autenticar |
secret | string | Clave secreta |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
HMAC-SHA256
Sección titulada «HMAC-SHA256»local hex = hash.hmac_sha256("message", "secret")local raw = hash.hmac_sha256("message", "secret", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Mensaje a autenticar |
secret | string | Clave secreta |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
HMAC-SHA512
Sección titulada «HMAC-SHA512»local hex = hash.hmac_sha512("message", "secret")local raw = hash.hmac_sha512("message", "secret", true)| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Mensaje a autenticar |
secret | string | Clave secreta |
raw | boolean? | Devolver bytes crudos en lugar de hex |
Devuelve: string, error
Hashes No Criptograficos
Sección titulada «Hashes No Criptograficos»Hash rapido para tablas hash y particionamiento.
local n = hash.fnv32("data")| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Datos a hashear |
Devuelve: number, error
Hash rapido con salida mas grande para reducir colisiones.
local n = hash.fnv64("data")| Parámetro | Tipo | Descripción |
|---|---|---|
data | string | Datos a hashear |
Devuelve: number, error
Errores
Sección titulada «Errores»| Condición | Tipo | Reintentable |
|---|---|---|
| Entrada no es string | errors.INVALID | no |
| Secreto no es string (HMAC) | errors.INVALID | no |
Consulte Manejo de Errores para trabajar con errores.