(publicKey, privateKey)
| 48 | |
| 49 | // Tests that a key pair can be used for encryption / decryption. |
| 50 | function 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. |
| 61 | function testSignVerify(publicKey, privateKey) { |
no test coverage detected