MCPcopy Index your code
hub / github.com/nodejs/node / testCipher2

Function testCipher2

test/parallel/test-crypto-cipheriv-decipheriv.js:45–61  ·  view source on GitHub ↗
(key, iv)

Source from the content-addressed store, hash-verified

43
44
45function testCipher2(key, iv) {
46 // Test encryption and decryption with explicit key and iv
47 const plaintext =
48 '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' +
49 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' +
50 'jAfaFg**';
51 const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv);
52 let ciph = cipher.update(plaintext, 'utf8', 'buffer');
53 ciph = Buffer.concat([ciph, cipher.final('buffer')]);
54
55 const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv);
56 let txt = decipher.update(ciph, 'buffer', 'utf8');
57 txt += decipher.final('utf8');
58
59 assert.strictEqual(txt, plaintext,
60 `encryption/decryption with key ${key} and iv ${iv}`);
61}
62
63
64function testCipher3(key, iv) {

Calls 3

concatMethod · 0.80
updateMethod · 0.65
finalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…