Crypto
aes_gcm bindings for lulu.
Methods
crypto.encrypt(key, nonce, data: ByteArray): Returns an encryptedByteArrayof supplied data.crypto.encrypt(key, nonce, data: ByteArray): Decrypts a provided encryptedByteArray.crypto.random_key(size): Provides aByteArrayof a key.crypto.random_nonce(size): Provides aByteArrayof a nonce.
using { lulib.crypto }
local key = crypto.random_key()
local nonce = crypto.random_nonce()
local entity = ByteArray("Data")
local encrypted = crypto.encrypt(key, nonce, entity)
local decrypted = try!
return Ok(crypto.decrypt(key, nonce, encrypted));
match(decrypted) do
if Err then
print("Decryption Failed")
if Ok then
local res = decrypted.unwrap():to_string()
print("Result: \"" .. res .. "\"")
end