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

Base64 decode doesn't give correct result #38

Closed
ovk opened this issue Aug 9, 2017 · 6 comments
Closed

Base64 decode doesn't give correct result #38

ovk opened this issue Aug 9, 2017 · 6 comments

Comments

@ovk
Copy link

ovk commented Aug 9, 2017

Please see this small example: https://jsfiddle.net/j1rp55oo/

You can check that Base64.encode(...) works correctly by decoding it's output using OpenSSL or any other base64 encoder. Base64.decode(...) on the other hand, returns complete garbage.

@Ruffio
Copy link

Ruffio commented Aug 10, 2017

I'm not at a computer for the rest of the weekend but base64 encoding/decoding can be performed natively by browsers by using atob and btoa.

@Ruffio
Copy link

Ruffio commented Aug 10, 2017

@ovk
Copy link
Author

ovk commented Aug 10, 2017

Thanks, I know about atob/btoa, but it's not supported in IE9, unfortuntely. So having working base64 encoding in jshashes still could be useful.

@0joshuaolson1
Copy link
Contributor

Yeah, that's a problem.

@ymlbright
Copy link

It should use i++ here: https://github.com/h2non/jshashes/blob/master/hashes.js#L331~L334 .
Then decode works for ASCII words.

@ymlbright
Copy link

We should update the input length after UTF-8 convert: https://github.com/h2non/jshashes/blob/master/hashes.js#L301.
Then encode works for UTF-8 words

@h2non h2non closed this as completed in 6dc3eb6 May 30, 2022
h2non added a commit that referenced this issue May 30, 2022
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

4 participants