We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0c44758 + fe4c2f5 commit 688dca6Copy full SHA for 688dca6
lib/protocol/Auth.js
@@ -2,12 +2,23 @@ var Buffer = require('buffer').Buffer;
2
var Crypto = require('crypto');
3
var Auth = exports;
4
5
-function sha1(msg) {
6
- var hash = Crypto.createHash('sha1');
7
- hash.update(msg);
8
- // hash.digest() does not output buffers yet
9
- return hash.digest('binary');
10
-};
+var sha1;
+if (Number(process.version.match(/^v\d+\.(\d+)/)[1]) >= 10){
+ sha1 = function(msg) {
+ var hash = Crypto.createHash('sha1');
+ hash.setEncoding('binary');
+ hash.write(msg);
11
+ hash.end();
12
+ return hash.read();
13
+ }
14
+} else {
15
16
17
+ hash.update(msg);
18
+ // hash.digest() does not output buffers yet
19
+ return hash.digest('binary');
20
21
+}
22
Auth.sha1 = sha1;
23
24
function xor(a, b) {
0 commit comments