Created
February 4, 2023 18:53
-
-
Save corocoto/2809363ea1b9ad521483e3e4fc4b5c96 to your computer and use it in GitHub Desktop.
RSA key pair generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const crypto = require('crypto'); | |
function generateKeyPair() { | |
const keyPair = crypto.generateKeyPairSync('rsa', { | |
modulusLength: 4096, | |
publicKeyEncoding: { | |
type: 'pkcs1', | |
format: 'pem' | |
}, | |
privateKeyEncoding: { | |
type: 'pkcs1', | |
format: 'pem' | |
} | |
}); | |
fs.writeFileSync(__dirname + '/id_rsa_pub.pem', keyPair.publicKey); | |
fs.writeFileSync(__dirname + '/id_rsa_priv.pem', keyPair.privateKey); | |
} | |
generateKeyPair(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment