28 lines
807 B
JavaScript
28 lines
807 B
JavaScript
const crypto = require('crypto');
|
|
|
|
const keys = crypto.generateKeyPairSync('rsa', {
|
|
modulusLength: 4096,
|
|
publicKeyEncoding: {
|
|
type: 'spki',
|
|
format: 'pem'
|
|
},
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'pem',
|
|
//cipher: 'aes-256-cbc',
|
|
//passphrase: 'top secret'
|
|
}
|
|
});
|
|
|
|
console.log(keys.publicKey);
|
|
console.log(keys.privateKey);
|
|
|
|
// const keys2 = crypto.generateKeyPairSync('rsa', {
|
|
// modulusLength: 4096
|
|
// });
|
|
|
|
// console.log(keys2.publicKey.export({ type: 'spki', format: 'pem' }));
|
|
// console.log(keys2.publicKey.export({ type: 'spki', format: 'der' }));
|
|
// console.log(keys2.privateKey.export({ type: 'pkcs8', format: 'pem' }));
|
|
// console.log(keys2.privateKey.export({ type: 'pkcs8', format: 'der' }));
|