Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

b64.encode_base64url problem #424

Open
axpwx opened this issue Mar 14, 2023 · 3 comments
Open

b64.encode_base64url problem #424

axpwx opened this issue Mar 14, 2023 · 3 comments

Comments

@axpwx
Copy link

axpwx commented Mar 14, 2023

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

@zhuizhuhaomeng
Copy link
Contributor

✗ echo -n CgIAiFs24JOIbXrLAAAAPBwznGIAAAAqwQPxMwAAABU94 | base64 -d 

[6ӈmzɼ3b*󿿃󱓽base64: invalid input

@axpwx
Copy link
Author

axpwx commented Mar 14, 2023

@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

@zhuizhuhaomeng
Copy link
Contributor

I think we won't support 'loose mode' in the near feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants