use ursa-optional or ursa
This commit is contained in:
parent
ff05912dfe
commit
c3ceffd2e2
|
@ -1,7 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function (bitlen, exp) {
|
||||
return require('ursa').generatePrivateKey(bitlen || 2048, exp || 65537).toPrivatePem().toString('ascii').trim();
|
||||
var ursa;
|
||||
try {
|
||||
ursa = require('ursa');
|
||||
} catch(e) {
|
||||
ursa = require('ursa-optional');
|
||||
}
|
||||
return ursa.generatePrivateKey(bitlen || 2048, exp || 65537).toPrivatePem().toString('ascii').trim();
|
||||
};
|
||||
|
||||
if (require.main === module) {
|
||||
|
|
Loading…
Reference in New Issue