add global bin for generating keypairs
This commit is contained in:
parent
982c13948a
commit
f3d8bb85c1
25
README.md
25
README.md
|
@ -9,6 +9,31 @@ This is useful for **certbot** and **letsencrypt**.
|
||||||
|
|
||||||
(in the future we'd like to provide the same API to the browser)
|
(in the future we'd like to provide the same API to the browser)
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
```
|
||||||
|
# node.js
|
||||||
|
npm install --save rsa-compat
|
||||||
|
|
||||||
|
# CLI
|
||||||
|
npm install --global rsa-compat
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
CLI
|
||||||
|
---
|
||||||
|
|
||||||
|
You can generate keypairs on Windows, Mac, and Linux using rsa-keygen-js:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# generates a new keypair in the current directory
|
||||||
|
rsa-keypiar-js
|
||||||
|
```
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var RSA = require('../').RSA;
|
||||||
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var bitlen = 2048;
|
||||||
|
var exp = 65537;
|
||||||
|
var opts = { public: true, pem: true };
|
||||||
|
var cwd = process.cwd();
|
||||||
|
var privkeyPath = path.join(cwd, 'privkey.pem');
|
||||||
|
var pubkeyPath = path.join(cwd, 'pubkey.pem');
|
||||||
|
|
||||||
|
if (fs.existsSync(privkeyPath)) {
|
||||||
|
console.error(privkeyPath, "already exists");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RSA.generateKeypair(bitlen, exp, opts, function (err, keypair) {
|
||||||
|
console.info('');
|
||||||
|
console.info('');
|
||||||
|
|
||||||
|
fs.writeFileSync(privkeyPath, keypair.privateKeyPem, 'ascii');
|
||||||
|
console.info(privkeyPath + ':');
|
||||||
|
console.info('');
|
||||||
|
console.info(keypair.privateKeyPem);
|
||||||
|
|
||||||
|
console.info('');
|
||||||
|
|
||||||
|
fs.writeFileSync(pubkeyPath, keypair.publicKeyPem, 'ascii');
|
||||||
|
console.info(pubkeyPath + ':');
|
||||||
|
console.info('');
|
||||||
|
console.info(keypair.publicKeyPem);
|
||||||
|
});
|
|
@ -3,6 +3,9 @@
|
||||||
"version": "1.2.6",
|
"version": "1.2.6",
|
||||||
"description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler",
|
"description": "RSA utils that work on Windows, Mac, and Linux with or without C compiler",
|
||||||
"main": "node.js",
|
"main": "node.js",
|
||||||
|
"bin": {
|
||||||
|
"rsa-keygen-js": "bin/rsa-keygen.js"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node tests"
|
"test": "node tests"
|
||||||
},
|
},
|
||||||
|
@ -36,7 +39,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Daplie/rsa-compat.js#readme",
|
"homepage": "https://github.com/Daplie/rsa-compat.js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"buffer-v6-polyfill": "^1.0.1",
|
"buffer-v6-polyfill": "^1.0.3",
|
||||||
"node-forge": "^0.6.41"
|
"node-forge": "^0.6.41"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
|
Loading…
Reference in New Issue