aes.lua: `s` passed to `_M.encrypt` appears to be table?
odiferousmint opened this issue · 1 comments
odiferousmint commented
I get the following error upon attempting to call encrypt
.
site/lualib/resty/aes.lua:191: bad argument #4 to 'EVP_EncryptUpdate' (cannot convert 'table' to 'const unsigned char *')
The Lua script is nothing fancy:
local aes = require "resty.aes"
local cipher = aes:new("secretKey")
local encryptedData, err = cipher:encrypt(sessionData)
if not encryptedData then
return err
end
If I shadow the s
variable in _M.encrypt(self, s)
, e.g. by doing local s = "foo"
, then the error disappears, so it definitely is s
that is the issue although I am not sure why s
is a table to begin with.
odiferousmint commented
Never mind, I do not think you are supposed to encrypt the whole session data, but encrypt a specific key's value instead.