File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
var crypto = require ( 'crypto' )
2
2
var tape = require ( 'tape' )
3
3
var Sha1 = require ( '../' ) . sha1
4
+ var sha = require ( '../' )
4
5
5
6
var inputs = [
6
7
[ '' , 'ascii' ] ,
@@ -25,6 +26,21 @@ tape("hash is the same as node's crypto", function (t) {
25
26
t . end ( )
26
27
} )
27
28
29
+ tape ( "hash is the same as node's crypto for all algos provided by node" , function ( t ) {
30
+ var hashes = crypto . getHashes ( )
31
+ Object . keys ( sha ) . forEach ( function ( alg ) {
32
+ if ( ! hashes . includes ( alg ) ) return // skip unsupported by current Node.js version
33
+ inputs . forEach ( function ( v ) {
34
+ var a = new sha [ alg ] ( ) . update ( v [ 0 ] , v [ 1 ] ) . digest ( 'hex' )
35
+ var e = crypto . createHash ( alg ) . update ( v [ 0 ] , v [ 1 ] ) . digest ( 'hex' )
36
+ console . log ( alg , a , '==' , e )
37
+ t . equal ( a , e )
38
+ } )
39
+ } )
40
+
41
+ t . end ( )
42
+ } )
43
+
28
44
tape ( 'call update multiple times' , function ( t ) {
29
45
inputs . forEach ( function ( v ) {
30
46
var hash = new Sha1 ( )
You can’t perform that action at this time.
0 commit comments