File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,23 @@ var Buffer = require('buffer').Buffer;
2
2
var Crypto = require ( 'crypto' ) ;
3
3
var Auth = exports ;
4
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
- } ;
5
+ var sha1 ;
6
+ if ( Number ( process . version . match ( / ^ v \d + \. ( \d + ) / ) [ 1 ] ) >= 10 ) {
7
+ sha1 = function ( msg ) {
8
+ var hash = Crypto . createHash ( 'sha1' ) ;
9
+ hash . setEncoding ( 'binary' ) ;
10
+ hash . write ( msg ) ;
11
+ hash . end ( ) ;
12
+ return hash . read ( ) ;
13
+ }
14
+ } else {
15
+ sha1 = function ( msg ) {
16
+ var hash = Crypto . createHash ( 'sha1' ) ;
17
+ hash . update ( msg ) ;
18
+ // hash.digest() does not output buffers yet
19
+ return hash . digest ( 'binary' ) ;
20
+ }
21
+ }
11
22
Auth . sha1 = sha1 ;
12
23
13
24
function xor ( a , b ) {
You can’t perform that action at this time.
0 commit comments