@@ -15,24 +15,28 @@ test('works...', (t) => {
15
15
} ) ;
16
16
17
17
test ( 'works with custom encoding' , ( t ) => {
18
- t . plan ( 1 ) ;
18
+ const encodings = [ 'hex' , 'base64' , 'latin1' ] ;
19
19
20
- const cryptr = new Cryptr ( testSecret , { encoding : 'base64' } ) ;
21
- const encryptedString = cryptr . encrypt ( testData ) ;
22
- const decryptedString = cryptr . decrypt ( encryptedString ) ;
20
+ t . plan ( encodings . length ) ;
23
21
24
- t . equal ( decryptedString , testData , 'decrypted aes256 correctly with custom encoding' ) ;
22
+ encodings . forEach ( ( encoding ) => {
23
+ const cryptr = new Cryptr ( testSecret , { encoding } ) ;
24
+ const encryptedString = cryptr . encrypt ( testData ) ;
25
+ const decryptedString = cryptr . decrypt ( encryptedString ) ;
26
+
27
+ t . equal ( decryptedString , testData , `decrypted correctly with ${ encoding } encoding` ) ;
28
+ } ) ;
25
29
} ) ;
26
30
27
31
test ( 'custom encoding affects output length' , ( t ) => {
28
- t . plan ( 1 ) ;
32
+ t . plan ( 1 ) ;
29
33
30
- const cryptr = new Cryptr ( testSecret , { encoding : 'base64' } ) ;
31
- const cryptr2 = new Cryptr ( testSecret ) ;
32
- const encryptedString = cryptr . encrypt ( testData ) ;
33
- const encryptedString2 = cryptr2 . encrypt ( testData ) ;
34
+ const cryptr = new Cryptr ( testSecret , { encoding : 'base64' } ) ;
35
+ const cryptr2 = new Cryptr ( testSecret ) ;
36
+ const encryptedString = cryptr . encrypt ( testData ) ;
37
+ const encryptedString2 = cryptr2 . encrypt ( testData ) ;
34
38
35
- t . ok ( encryptedString . length < encryptedString2 . length , 'custom encoding was shorter' ) ;
39
+ t . ok ( encryptedString . length < encryptedString2 . length , 'custom encoding was shorter' ) ;
36
40
} ) ;
37
41
38
42
test ( 'works with custom pbkdf2Iterations' , ( t ) => {
0 commit comments