Skip to content

Commit 8954724

Browse files
Aileenaddaleax
authored andcommitted
test: refactor test-crypto-cipheriv-decipheriv
Make change in test file from var to const/let. PR-URL: #10018 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent c4277d9 commit 8954724

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

‎test/parallel/test-crypto-cipheriv-decipheriv.js‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
2+
constcommon=require('../common');
3+
constassert=require('assert');
44

55
if(!common.hasCrypto){
66
common.skip('missing crypto');
77
return;
88
}
9-
varcrypto=require('crypto');
9+
constcrypto=require('crypto');
1010

1111
functiontestCipher1(key,iv){
1212
// Test encyrption and decryption with explicit key and iv
13-
varplaintext=
14-
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw'+
15-
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ'+
16-
'jAfaFg**';
17-
varcipher=crypto.createCipheriv('des-ede3-cbc',key,iv);
18-
varciph=cipher.update(plaintext,'utf8','hex');
13+
constplaintext=
14+
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw'+
15+
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ'+
16+
'jAfaFg**';
17+
constcipher=crypto.createCipheriv('des-ede3-cbc',key,iv);
18+
letciph=cipher.update(plaintext,'utf8','hex');
1919
ciph+=cipher.final('hex');
2020

21-
vardecipher=crypto.createDecipheriv('des-ede3-cbc',key,iv);
22-
vartxt=decipher.update(ciph,'hex','utf8');
21+
constdecipher=crypto.createDecipheriv('des-ede3-cbc',key,iv);
22+
lettxt=decipher.update(ciph,'hex','utf8');
2323
txt+=decipher.final('utf8');
2424

2525
assert.strictEqual(txt,plaintext,'encryption/decryption with key and iv');
@@ -28,11 +28,11 @@ function testCipher1(key, iv){
2828
// NB: In real life, it's not guaranteed that you can get all of it
2929
// in a single read() like this. But in this case, we know it's
3030
// quite small, so there's no harm.
31-
varcStream=crypto.createCipheriv('des-ede3-cbc',key,iv);
31+
constcStream=crypto.createCipheriv('des-ede3-cbc',key,iv);
3232
cStream.end(plaintext);
3333
ciph=cStream.read();
3434

35-
vardStream=crypto.createDecipheriv('des-ede3-cbc',key,iv);
35+
constdStream=crypto.createDecipheriv('des-ede3-cbc',key,iv);
3636
dStream.end(ciph);
3737
txt=dStream.read().toString('utf8');
3838

@@ -42,16 +42,16 @@ function testCipher1(key, iv){
4242

4343
functiontestCipher2(key,iv){
4444
// Test encyrption and decryption with explicit key and iv
45-
varplaintext=
46-
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw'+
47-
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ'+
48-
'jAfaFg**';
49-
varcipher=crypto.createCipheriv('des-ede3-cbc',key,iv);
50-
varciph=cipher.update(plaintext,'utf8','buffer');
45+
constplaintext=
46+
'32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw'+
47+
'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ'+
48+
'jAfaFg**';
49+
constcipher=crypto.createCipheriv('des-ede3-cbc',key,iv);
50+
letciph=cipher.update(plaintext,'utf8','buffer');
5151
ciph=Buffer.concat([ciph,cipher.final('buffer')]);
5252

53-
vardecipher=crypto.createDecipheriv('des-ede3-cbc',key,iv);
54-
vartxt=decipher.update(ciph,'buffer','utf8');
53+
constdecipher=crypto.createDecipheriv('des-ede3-cbc',key,iv);
54+
lettxt=decipher.update(ciph,'buffer','utf8');
5555
txt+=decipher.final('utf8');
5656

5757
assert.strictEqual(txt,plaintext,'encryption/decryption with key and iv');

0 commit comments

Comments
(0)