lua-resty-core
lua-resty-core copied to clipboard
b64.encode_base64url problem
local str = 'CgIAiFs24JOIbXrLAAAAPBwznGIAAAAqwQPxMwAAABU94'
res, err = b64.decode_base64url(str)
if err then
ngx.log(ngx.ERR, err)
-- output: invalid input
end
openresty: 1.19.9.1 resty.core: 0.1.22
✗ echo -n CgIAiFs24JOIbXrLAAAAPBwznGIAAAAqwQPxMwAAABU94 | base64 -d
[6ӈmzɼ3b*base64: invalid input
@zhuizhuhaomeng
echo -n CgIAiFs24JOIbXrLAAAAPBwznGIAAAAqwQPxMwAAABU94 | base64 -d | xxd -ps
base64: invalid input
0a0200885b36e093886d7acb0000003c1c339c620000002ac103f1330000
00153d
I can extract the string "5b36e093".
If decode_base64url has "loose mode", this code be works:
local str = 'CgIAiFs24JOIbXrLAAAAPBwznGIAAAAqwQPxMwAAABU94'
res, err = b64.decode_base64url(str)
if res then
tohex(res)
...
else
-- err
end
I think we won't support 'loose mode' in the near feature.