-
Notifications
You must be signed in to change notification settings - Fork 2.5k
crypto.createHash fix for node.js < 11 #735
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
Conversation
👍 lgtm |
Since the version of node.js does not change at runtime, the var sha1;
if (Number(process.version.match(/^v\d+\.(\d+)/)[1]) >= 10){
sha1 = function sha1(msg) {
var hash = Crypto.createHash('sha1');
hash.setEncoding('binary');
hash.write(msg);
hash.end();
return hash.read();
};
} else {
sha1 = function sha1(msg) {
var hash = Crypto.createHash('sha1');
hash.update(msg);
// hash.digest() does not output buffers yet
return hash.digest('binary');
};
} |
Is there a consensus with what @dougwilson has suggested? I will update the pr in the morning. |
@jas- yeah, I like @dougwilson suggestion |
@sidorares @dougwilson pr has been updated to reflect recommendations in comment #35435407. Thanks, I wouldn't have thought of that. |
hash.update(msg); | ||
// hash.digest() does not output buffers yet | ||
return hash.digest('binary'); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary semicolon
Looks good to me 👍 |
@dougwilson Fixed the semicolon |
@jas- ooo, so fast :) |
@dougwilson I have time to address things like this right now when it relates to dependencies for another project. :) |
crypto.createHash fix for node.js < 11
thanks guys :) |
Thanks from me as well @sidorares & @dougwilson |
@sidorares or @dougwilson Sorry to bug you, but is this get handed over to the npm registry so I can update my package.json to use that or should I just use the github repo for now? |
@jas- I don't think you are bugging us :) If you need the fix ASAP and you don't check in your @sidorares may be able to weigh in on the timeline of a new release on |
@jas- @dougwilson I updated changelog and tagged v2.1.0 release but having some strange npm errors
@dougwilson - could you try to publish yourself? You seem to have npm access rights |
@sidorares I just tried and am getting the same error. Searching for |
Oh, I just got it to publish. @jas- 2.1.0 is on |
You guys are quick, thanks! |
@jas- I see your comment is deleted now :) I think |
@dougwilson Yeah, I was quick to comment. Sorry about that! |
Hi @jas-, it has turned out this commit broke sha1 in the early versions on node.js 0.10. What was the specific version on node.js you were using where the old sha1 method was not functioning? The commit message leads me to believe that before this it was broken on node.js < 0.11, but perhaps you meant > 0.11? The weird part is it looks like |
@dougwilson Strange because I have tested it with Perhaps further version tests are in order? I have encountered the same problem when enabling the tls module What versions (specifically) does the pr break? And your right, the |
It breaks under node.js 0.10.1, 0.10.2 and 0.10.5 (these are all confirmed). Since the old sha1 function works under all node.js 0.10, how about I change it so the new sha1 you implemented is just for 0.11+? |
@jas- the commit nodejs/node-v0.x-archive@4bf1d10 is where it changed in node.js; before that, your call to Even after that commit, it seems something it not working correctly with the sha1 function. TL;DR node.js >= 0.10.0 and < 0.10.5 the sha1 function will blow up. node.js 0.10.5 to something the call does not blow up, but seems to not return the correct results. You can refer to #746 as well. |
@jas- as a further update, due to bug fixed in commit nodejs/node-v0.x-archive@d515857 before node.js 0.10.6, the call to |
This PR will update the
sha1()
function @ lib/protocol/Auth.js to update thecrypto.createHash
function to use the.write()
&.end()
functions vs. the depreciated.update()
&.digest()
methods when working with node.js < v0.10.*I tried finding the exact version which removes the
.update()
&.digest()
functions and through my tests I could only determine it to be betweenv0.9.*
&v0.10.*
.