Skip to content

Lua API Crypto

Leonard Ramminger edited this page Aug 10, 2026 · 1 revision

Lua API — Crypto (beez.crypto)

Hash files and strings, encode bytes, and compute HMAC digests.


Functions

Function Input Output
list_hash_algo() — { "sha256", …, "sdbm" }
list_encode_algo() — { "hex", "base64" }
is_hash(name) string boolean
is_encoding_algo(name) string boolean
hash_string(data, algorithm) string, string hex digest
hash_file(path, [algorithm]) path, string? hex digest (default sha256)
encode(data) string hex
encode(data, encoding) string, "hex"|"base64" encoded string
encode(data, key, hash) string, string, string HMAC hex

Hash algorithms

  • Digests: sha256, sha512, sha1, md5
  • Fingerprints: fnv1a64, fnv1a32, crc32, djb2, sdbm

Examples

local sha = beez.crypto.hash_string("payload", "sha256")
local file_hash = beez.crypto.hash_file("dist/app.tar.gz")
local b64 = beez.crypto.encode("hello", "base64")
local mac = beez.crypto.encode("message", "secret-key", "sha256")

Use with beez.net.download_and_verify to verify downloads.


← Lua API Overview

Clone this wiki locally