1- var test = require ( 'tape' ) ;
2- var crypto = require ( 'browserify-aes/browser' ) ;
3- var randomBytes = require ( 'randombytes' ) ;
1+ var test = require ( 'tape' )
2+ var crypto = require ( 'browserify-aes/browser' )
3+ var randomBytes = require ( 'randombytes' )
4+
45test ( 'ciphers' , function ( t ) {
56 crypto . listCiphers ( ) . forEach ( function ( cipher ) {
67 t . test ( cipher , function ( t ) {
7- t . plan ( 1 ) ;
8- var data = randomBytes ( 562 ) ;
9- var password = randomBytes ( 20 ) ;
10- var crypter = crypto . createCipher ( cipher , password ) ;
11- var decrypter = crypto . createDecipher ( cipher , password ) ;
12- var out = [ ] ;
13- out . push ( decrypter . update ( crypter . update ( data ) ) ) ;
14- out . push ( decrypter . update ( crypter . final ( ) ) ) ;
8+ t . plan ( 1 )
9+ var data = randomBytes ( 562 )
10+ var password = randomBytes ( 20 )
11+ var crypter = crypto . createCipher ( cipher , password )
12+ var decrypter = crypto . createDecipher ( cipher , password )
13+ var out = [ ]
14+ out . push ( decrypter . update ( crypter . update ( data ) ) )
15+ out . push ( decrypter . update ( crypter . final ( ) ) )
1516 if ( cipher . indexOf ( 'gcm' ) > - 1 ) {
16- decrypter . setAuthTag ( crypter . getAuthTag ( ) ) ;
17+ decrypter . setAuthTag ( crypter . getAuthTag ( ) )
1718 }
18- out . push ( decrypter . final ( ) ) ;
19- t . equals ( data . toString ( 'hex' ) , Buffer . concat ( out ) . toString ( 'hex' ) ) ;
20- } ) ;
21- } ) ;
22- } ) ;
19+ out . push ( decrypter . final ( ) )
20+ t . equals ( data . toString ( 'hex' ) , Buffer . concat ( out ) . toString ( 'hex' ) )
21+ } )
22+ } )
23+ } )
24+
2325test ( 'getCiphers' , function ( t ) {
24- t . plan ( 1 ) ;
25- t . ok ( crypto . getCiphers ( ) . length , 'get ciphers returns an array' ) ;
26- } ) ;
26+ t . plan ( 1 )
27+ t . ok ( crypto . getCiphers ( ) . length , 'get ciphers returns an array' )
28+ } )
29+
2730test ( 'through crypto browserify works' , function ( t ) {
28- t . plan ( 2 ) ;
29- var crypto = require ( '../' ) ;
30- var cipher = 'aes-128-ctr' ;
31- var data = randomBytes ( 562 ) ;
32- var password = randomBytes ( 20 ) ;
33- var crypter = crypto . createCipher ( cipher , password ) ;
34- var decrypter = crypto . createDecipher ( cipher , password ) ;
35- var out = [ ] ;
36- out . push ( decrypter . update ( crypter . update ( data ) ) ) ;
37- out . push ( decrypter . update ( crypter . final ( ) ) ) ;
38- out . push ( decrypter . final ( ) ) ;
39- t . equals ( data . toString ( 'hex' ) , Buffer . concat ( out ) . toString ( 'hex' ) ) ;
40- t . ok ( crypto . getCiphers ( ) . length , 'get ciphers returns an array' ) ;
41- } ) ;
31+ t . plan ( 2 )
32+ var crypto = require ( '../' )
33+ var cipher = 'aes-128-ctr'
34+ var data = randomBytes ( 562 )
35+ var password = randomBytes ( 20 )
36+ var crypter = crypto . createCipher ( cipher , password )
37+ var decrypter = crypto . createDecipher ( cipher , password )
38+ var out = [ ]
39+ out . push ( decrypter . update ( crypter . update ( data ) ) )
40+ out . push ( decrypter . update ( crypter . final ( ) ) )
41+ out . push ( decrypter . final ( ) )
42+ t . equals ( data . toString ( 'hex' ) , Buffer . concat ( out ) . toString ( 'hex' ) )
43+ t . ok ( crypto . getCiphers ( ) . length , 'get ciphers returns an array' )
44+ } )
0 commit comments