-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.lua
More file actions
24 lines (21 loc) · 592 Bytes
/
test.lua
File metadata and controls
24 lines (21 loc) · 592 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local hydrogen = require "hydrogen"
do
local secretbox = hydrogen.secretbox
pcall(function()
secretbox.newkey("123456789123")
end)
local key = secretbox.keygen()
local plaintext = "my message"
local ciphertext = secretbox.encrypt(plaintext, 0, "8bytectx", key)
assert(secretbox.decrypt(ciphertext, 0, "8bytectx", key) == plaintext)
end
do
local hash = hydrogen.hash
local state = hash.init("8bytectx", "some_32_byte_key________________")
state:update("some data")
print(state:final())
end
do
assert(hydrogen.bin2hex("\0") == "00")
assert(hydrogen.hex2bin("00") == "\0")
end