@@ -11,37 +11,37 @@ var crypto = require('crypto');
11
11
crypto . DEFAULT_ENCODING = 'buffer' ;
12
12
13
13
function aes256 ( decipherFinal ) {
14
- var iv = Buffer . from ( '00000000000000000000000000000000' , 'hex' ) ;
15
- var key = Buffer . from ( '0123456789abcdef0123456789abcdef' +
16
- '0123456789abcdef0123456789abcdef' , 'hex' ) ;
14
+ const iv = Buffer . from ( '00000000000000000000000000000000' , 'hex' ) ;
15
+ const key = Buffer . from ( '0123456789abcdef0123456789abcdef' +
16
+ '0123456789abcdef0123456789abcdef' , 'hex' ) ;
17
17
18
18
function encrypt ( val , pad ) {
19
- var c = crypto . createCipheriv ( 'aes256' , key , iv ) ;
19
+ const c = crypto . createCipheriv ( 'aes256' , key , iv ) ;
20
20
c . setAutoPadding ( pad ) ;
21
21
return c . update ( val , 'utf8' , 'latin1' ) + c . final ( 'latin1' ) ;
22
22
}
23
23
24
24
function decrypt ( val , pad ) {
25
- var c = crypto . createDecipheriv ( 'aes256' , key , iv ) ;
25
+ const c = crypto . createDecipheriv ( 'aes256' , key , iv ) ;
26
26
c . setAutoPadding ( pad ) ;
27
27
return c . update ( val , 'latin1' , 'utf8' ) + c [ decipherFinal ] ( 'utf8' ) ;
28
28
}
29
29
30
30
// echo 0123456789abcdef0123456789abcdef \
31
31
// | openssl enc -e -aes256 -nopad -K <key> -iv <iv> \
32
32
// | openssl enc -d -aes256 -nopad -K <key> -iv <iv>
33
- var plaintext = '0123456789abcdef0123456789abcdef' ; // multiple of block size
34
- var encrypted = encrypt ( plaintext , false ) ;
35
- var decrypted = decrypt ( encrypted , false ) ;
36
- assert . equal ( decrypted , plaintext ) ;
33
+ let plaintext = '0123456789abcdef0123456789abcdef' ; // multiple of block size
34
+ let encrypted = encrypt ( plaintext , false ) ;
35
+ let decrypted = decrypt ( encrypted , false ) ;
36
+ assert . strictEqual ( decrypted , plaintext ) ;
37
37
38
38
// echo 0123456789abcdef0123456789abcde \
39
39
// | openssl enc -e -aes256 -K <key> -iv <iv> \
40
40
// | openssl enc -d -aes256 -K <key> -iv <iv>
41
41
plaintext = '0123456789abcdef0123456789abcde' ; // not a multiple
42
42
encrypted = encrypt ( plaintext , true ) ;
43
43
decrypted = decrypt ( encrypted , true ) ;
44
- assert . equal ( decrypted , plaintext ) ;
44
+ assert . strictEqual ( decrypted , plaintext ) ;
45
45
}
46
46
47
47
aes256 ( 'final' ) ;
0 commit comments