Yuari
Documentation
Docs/Crypt

Crypt

Base64, hashing, HMAC, encryption, random bytes and LZ4 compression.

Base64 helpers. Also base64_encode / base64_decode, base64.encode / base64.decode, and crypt.base64encode / crypt.base64decode.

local encoded = base64encode("hello")
print(encoded, base64decode(encoded))

Symmetric encryption. mode defaults to CBC.

local key = crypt.generatekey(32)
local iv = crypt.generatebytes(16)
local encrypted = crypt.encrypt("secret", key, iv, "CBC")
print(crypt.decrypt(encrypted, key, iv, "CBC"))

Random bytes or key.

print(#crypt.generatebytes(16), #crypt.generatekey(32))

Hashes data. Default algorithm: sha384.

print(crypt.hash("hello", "sha256"))

HMAC. Default algorithm: sha256.

print(crypt.hmac("key", "hello", "sha256"))

Returns a random number.

print(crypt.random(8))

LZ4 helpers, also on crypt.

local packed = lz4compress(string.rep("a", 1000))
print(#packed, #lz4decompress(packed))

Returns a function hash.

print(getfunctionhash(print))

Table aliases for the Base64 and LZ4 helpers.

local encoded = crypt.base64encode("hello")
print(crypt.base64decode(encoded))
print(crypt.lz4decompress(crypt.lz4compress("data")))