rzcoder / node-rsa

Node.js RSA library
1.39k stars 205 forks source link

Encrypted Private Key? #188

Open ddzobov opened 3 years ago

ddzobov commented 3 years ago

Can this library generate and work with encrypted private keys?

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

dejaime commented 3 years ago

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);