Created
September 13, 2023 15:05
-
-
Save nonseodion/2946b596c2ae2a7b383972150de574fe to your computer and use it in GitHub Desktop.
Generate public and private RSA Keys
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
// run this script in a nodejs environment | |
let {privateKey, publicKey} = crypto.generateKeyPairSync("rsa", {modulusLength: 512}) | |
publickKey = publicKey.export({type: "pkcs1", format: "pem"}) | |
privateKey = privateKey.export({type: "pkcs1", format: "pem"}) | |
// publicKey value | |
// '-----BEGIN RSA PUBLIC KEY-----\n' + | |
// 'MEgCQQC5GmUc8KaG8LuRYu0KmuAuMkqX8hEhjEXeWaXZpg6rz8CTLsKK1JaTnrqk\n' + | |
// 'G9jVrJExmZ+jqXk7Ll5awzDRbV/HAgMBAAE=\n' + | |
// '-----END RSA PUBLIC KEY-----\n' | |
// privateKey value | |
//'-----BEGIN RSA PRIVATE KEY-----\n' + | |
// 'MIIBOgIBAAJBALkaZRzwpobwu5Fi7Qqa4C4ySpfyESGMRd5ZpdmmDqvPwJMuworU\n' + | |
// 'lpOeuqQb2NWskTGZn6OpeTsuXlrDMNFtX8cCAwEAAQJBALh4bqZtyngWt8dHgJae\n' + | |
// 'DKbdZeuRybLWWdcjHp8O1/YuboVqC9RbOw6Wu1eC8UM0+4JN8DlRLgaR8PndLmIr\n' + | |
// 'FAECIQDbbeSoZAQ6Dr2DWatYe9goe02ZKa9OFnFCh8OjI94uAQIhANfz846ExycV\n' + | |
// 'g2qm78p1PAlD3eYEcmKFOjE82Jl/gZ3HAiAPfs8q5QU3ZFsVr3teIEC/exWbv0nV\n' + | |
// '5dfRruyt1JaYAQIgEMxvQ8TcYRPxVxiJSqx38RiQaFYsN7G5Zx8ekkIy6P0CIHp3\n' + | |
// 'Nf9jf9AizYNYQhYscW1Imm96zZZTxjL/T5u7YMFQ\n' + | |
// '-----END RSA PRIVATE KEY-----\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment