Skip to content

Commit 160d038

Browse files
radelmannitaloacasas
authored andcommitted
test: refactor test-crypto-padding-aes256
* replace var with const/let * replace assert.equal() with assert.strictEqual() PR-URL: #10622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent cb111c9 commit 160d038

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/parallel/test-crypto-padding-aes256.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@ var crypto = require('crypto');
1111
crypto.DEFAULT_ENCODING = 'buffer';
1212

1313
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');
1717

1818
function encrypt(val, pad) {
19-
var c = crypto.createCipheriv('aes256', key, iv);
19+
const c = crypto.createCipheriv('aes256', key, iv);
2020
c.setAutoPadding(pad);
2121
return c.update(val, 'utf8', 'latin1') + c.final('latin1');
2222
}
2323

2424
function decrypt(val, pad) {
25-
var c = crypto.createDecipheriv('aes256', key, iv);
25+
const c = crypto.createDecipheriv('aes256', key, iv);
2626
c.setAutoPadding(pad);
2727
return c.update(val, 'latin1', 'utf8') + c[decipherFinal]('utf8');
2828
}
2929

3030
// echo 0123456789abcdef0123456789abcdef \
3131
// | openssl enc -e -aes256 -nopad -K <key> -iv <iv> \
3232
// | 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);
3737

3838
// echo 0123456789abcdef0123456789abcde \
3939
// | openssl enc -e -aes256 -K <key> -iv <iv> \
4040
// | openssl enc -d -aes256 -K <key> -iv <iv>
4141
plaintext = '0123456789abcdef0123456789abcde'; // not a multiple
4242
encrypted = encrypt(plaintext, true);
4343
decrypted = decrypt(encrypted, true);
44-
assert.equal(decrypted, plaintext);
44+
assert.strictEqual(decrypted, plaintext);
4545
}
4646

4747
aes256('final');

0 commit comments

Comments
 (0)