23 lines
		
	
	
		
			439 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			439 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| '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));
 | |
| }
 |