File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ var test = require ( "tape" )
2
+
3
+ var crypto = require ( 'crypto' )
4
+ var cryptoB = require ( '../' )
5
+
6
+ function assertSame ( fn ) {
7
+ test ( fn . name , function ( t ) {
8
+ t . plan ( 1 )
9
+ fn ( crypto , function ( err , expected ) {
10
+ fn ( cryptoB , function ( err , actual ) {
11
+ t . equal ( actual , expected )
12
+ t . end ( )
13
+ } )
14
+ } )
15
+ } )
16
+ }
17
+
18
+ assertSame ( function sha1 ( crypto , cb ) {
19
+ cb ( null , crypto . createHash ( 'sha1' ) . update ( 'hello' , 'utf-8' ) . digest ( 'hex' ) )
20
+ } )
21
+
22
+ assertSame ( function md5 ( crypto , cb ) {
23
+ cb ( null , crypto . createHash ( 'md5' ) . update ( 'hello' , 'utf-8' ) . digest ( 'hex' ) )
24
+ } )
25
+
26
+ test ( 'randomBytes' , function ( t ) {
27
+ t . plan ( 5 )
28
+ t . equal ( cryptoB . randomBytes ( 10 ) . length , 10 )
29
+ t . ok ( cryptoB . randomBytes ( 10 ) instanceof Buffer )
30
+ cryptoB . randomBytes ( 10 , function ( ex , bytes ) {
31
+ t . error ( ex )
32
+ t . equal ( bytes . length , 10 )
33
+ t . ok ( bytes instanceof Buffer )
34
+ t . end ( )
35
+ } )
36
+ } )
You can’t perform that action at this time.
0 commit comments