local lu = require("luaunit") local aes = require("resty.openssl.cipher") function test_aes() local aes1 = aes.new(nil) local aes2 = aes.new(nil) local enc1 = assert(aes1:encrypt("a", nil, "test", nil, nil)) local enc2 = assert(aes2:encrypt("b", nil, "other", nil, nil)) local tag1 = aes1:get_aead_tag() local tag2 = aes2:get_aead_tag() local aes3 = aes.new(nil) local aes4 = aes.new(nil) lu.assertEquals(#tag1, 16) lu.assertEquals(#tag2, 16) lu.assertNotEquals(enc1, "test") lu.assertNotEquals(enc2, "other") lu.assertNotEquals(enc1 .. tag1, "test") lu.assertNotEquals(enc2 .. tag2, "other") lu.assertEquals(aes3:decrypt("a", nil, enc1, nil, nil, tag1), "test") lu.assertEquals(aes4:decrypt("b", nil, enc2, nil, nil, tag2), "other") end os.exit(lu.LuaUnit.run())