rsa-compat.js/lib/generate-privkey-node.js

23 lines
439 B
JavaScript
Raw Normal View History

2018-12-16 05:31:17 +00:00
'use strict';
module.exports = function (bitlen, exp) {
return require('crypto').generateKeyPairSync(
'rsa'
, { modulusLength: bitlen
, publicExponent: exp
, privateKeyEncoding: {
type: 'pkcs8'
, format: 'pem'
}
, publicKeyEncoding: {
type: 'spki'
, format: 'pem'
}
}
).privateKey.trim();
};
if (require.main === module) {
console.log(module.exports(2048, 0x10001));
}