Closed qqlee closed 7 years ago
It is not an issue, see: resty.nettle.padding.*. Please pad before encrypting and unpad with similar algo after decrypting. We may add another parameter in a future. AES is a block cipher and it works in 16 bytes blocks. In binary formats \0
can mean something. Only way to to go forward, AFAIK, is to pad.
thanks
local aes = require "resty.nettle.aes" local aes128 = aes.new("1234567812345678")
local str = "aaa" local ciphertext = aes128:encrypt(str) ngx.say(#str) -- print 3
local plaintext = aes128:decrypt(ciphertext) ngx.say(#plaintext) -- print 16
-- i need replace \0 local str = ngx.re.gsub(plaintext, [[\x00]], "") ngx.say(#str) --print 3