node-rsa icon indicating copy to clipboard operation
node-rsa copied to clipboard

Encrypted Private Key?

Open ddzobov opened this issue 3 years ago • 1 comments

Can this library generate and work with encrypted private keys?

-----BEGIN ENCRYPTED PRIVATE KEY-----

ddzobov avatar Nov 26 '20 21:11 ddzobov

No, apparently not. Check this other issue . You're probably better off using standard crypto anyway.

const crypto = require('crypto');
const MyEncryptedPrivKey = require('fs').readFileSync('./keys/enc_private.pem').toString();
const EncryptedData = [...];

let DecryptedData = crypto.privateDecrypt({
    key: MyEncryptedPrivKey,
    passphrase: "MY_PRIVATE_KEY_AWESOME_PASSWORD",
}, EncryptedData);

dejaime avatar Nov 26 '20 23:11 dejaime