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

Bug in sha implementation (likely due to international characters) #37

Closed
boucher opened this issue May 19, 2016 · 10 comments
Closed

Bug in sha implementation (likely due to international characters) #37

boucher opened this issue May 19, 2016 · 10 comments

Comments

@boucher
Copy link

boucher commented May 19, 2016

You can see the bug in this example:
https://tonicdev.com/boucher/573e107d8596081100e6a4d9

The hash returned from sha.js should be the same as the one from the built in crypto package, but isn't.

@fanatid
Copy link
Contributor

fanatid commented May 19, 2016

$ node -v
v6.1.0
$ npm ls --depth=0 | grep sha.js
`-- [email protected]
$ node
var s = 'Русский язык1'
var SHA1 = require('sha.js').sha1
new SHA1().update(s).digest('hex')
// => 43078a51a0771278729e446a587b0442fecebfcd
require('crypto').createHash('sha1').update(s).digest('hex')
// => 43078a51a0771278729e446a587b0442fecebfcd

ЧЯДНТ?

@fanatid
Copy link
Contributor

fanatid commented May 19, 2016

@boucher should I run test in browser instead node?

@boucher
Copy link
Author

boucher commented May 19, 2016

Run it in any version of node prior to 6

@fanatid
Copy link
Contributor

fanatid commented May 19, 2016

nodejs/node#5522
It's not a bug, crypto-browserify just not supported node 6 yet..

$ node -v
v6.1.0
$ npm ls --depth=0 | grep sha.js
`-- [email protected]
$ node
var s = 'Русский язык1'
require('crypto').createHash('sha1').update(s).digest('hex')
// => 43078a51a0771278729e446a587b0442fecebfcd
require('crypto').createHash('sha1').update(new Buffer(s, 'binary')).digest('hex')
// => 26c13d4b707714600f2aa1a60b4147bb3ba28868

@fanatid fanatid closed this as completed May 19, 2016
@fanatid
Copy link
Contributor

fanatid commented May 19, 2016

not sure, but #36 should fix this

@boucher
Copy link
Author

boucher commented May 19, 2016

The issue is not that things do not work in Node 6, they don't work in Node 5 or earlier (and they don't work in the browser, which is where support is critical).

@boucher
Copy link
Author

boucher commented May 19, 2016

If you download the zip file in the linked issue above (node-browserify#1553) you can get a complete example you can run yourself.

@fanatid
Copy link
Contributor

fanatid commented May 19, 2016

Argh, totally missed up with this..
You were right, it wasn't consistent with node < 6, but we can't support all node versions at one moment!
Since node 6 convert input to Buffer with utf8, I don't think that we should fix something here.

@boucher
Copy link
Author

boucher commented May 19, 2016

:( This means that browserify is broken in anything less than Node 6,
including Node 4 which is theoretically the most stable current release.

On Thu, May 19, 2016 at 4:30 PM Kirill Fomichev [email protected]
wrote:

Argh, totally missed up with this..
You were right, it wasn't consistent with node < 6, but we can't support
all node versions at one moment!
Since node 6 convert input to Buffer with utf8, I don't think that we
should fix something here.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#37 (comment)

@dcousens
Copy link
Member

You were right, it wasn't consistent with node < 6, but we can't support all node versions at one moment!

Can you elaborate on your findings?

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

3 participants