-
Notifications
You must be signed in to change notification settings - Fork 33
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
Unicode issue #10
Comments
Found out the reason: JS strings are UTF16-stored, while PHP assumes multi-byte with UTF8. Fix is easy with the library at http://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt; I described the usage in http://stackoverflow.com/questions/19835609/differing-sha1-hashes-for-identical-values-on-the-server-and-the-client/21341088#21341088 where someone had a similar issue. Might be worth to incorporate this conversion into the digest function? |
Yes, it might be worth adding an Would you like to make the change and submit a PR? |
I'm not that deep into JS, can you please do it? |
I'm a bit short on time at the moment, but I'll see if I can get around to it sometime next week. Anyway, thanks for pointing that out! |
I'll submit a patch that runs |
Where exactly would I insert that? https://github.com/srijs/rusha/blob/master/rusha.js#L164 looks like a good candidate. |
Hi. Please modify rusha.sweet.js. A good candidate would be the |
@sergeevabc in case you still need it - from the documentation (readme) So the library will not work on arbitrary strings
|
Thanks for your input, @szydan. At that time I chose Fast SHA256. |
Closing this as wontfix -- Rusha is not meant to be used directly on encoded strings with code-points above 255. If you want to hash strings like these, please be sure to convert them into the desired binary encoding beforehand. |
Hi,
I'm having problems using rusha for comparing a string in Javascript with the same string hashed in PHP.
In Javascript, I use
and in PHP (once using a literal ä, once a json-decode'd ä to rule out a bug in PHP or my file encoding)
which gives me the output
Why are the SHA1 hashes different? After all, using the \u00e4 notation should result in the same byte sequence both in a PHP string and a Javascript string, right?
The text was updated successfully, but these errors were encountered: