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

Function testEncryptDecrypt

test/common/crypto.js:50–58  ·  view source on GitHub ↗
(publicKey, privateKey)

Source from the content-addressed store, hash-verified

48
49// Tests that a key pair can be used for encryption / decryption.
50function testEncryptDecrypt(publicKey, privateKey) {
51 const message = 'Hello Node.js world!';
52 const plaintext = Buffer.from(message, 'utf8');
53 for (const key of [publicKey, privateKey]) {
54 const ciphertext = publicEncrypt(key, plaintext);
55 const received = privateDecrypt(privateKey, ciphertext);
56 assert.strictEqual(received.toString('utf8'), message);
57 }
58}
59
60// Tests that a key pair can be used for signing / verification.
61function testSignVerify(publicKey, privateKey) {

Calls 2

fromMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected