0.6.1 • Published 6 years ago

rsa-key-gen v0.6.1

Weekly downloads
23
License
BSD-3-Clause
Repository
github
Last release
6 years ago

rsa-key-gen

Current Version dependency Status devDependency Status Build Status Windows Build Status Coveralls

An implementation of openssl genrsa for node.

It makes use of pem module which is dependant upon openssl binary to work as is a wrapper to the command line tool.

Install

$ npm install rsa-key-gen

Usage

rsaKeyGen.generateKeyPair(options, callback)

(Callback) with error and result signature

options:

  • bits key length in bits
  • cipher default: aes256 see openssl man page for valid options
  • password: string password for key pair

    If no options parameter is used bits defaults to 4096 and cipher to 'aes256'

Example

const rsaKeyGen = require('rsa-key-gen');

const options = {
    bits: 4096,
    cipher: 'camellia256',
    password: 'secret'
};

rsaKeyGen.generateKeyPair(options, (err, result) => {

    if (err) {
        throw err
    }
    // Print keypair to console
    console.log('%s\n\n%s', result.private, result.public);

});

rsaKeyGen.generateCertificate(options, callback)

(Callback) with error and result signature

options

  • selfSigned boolean
  • bits length in bits for certificate

    If no options parameter is used bits defaults to 4096 and selfSigned to true

    Other valid options are described in the pem modules docs

const options = {
   bits: 4096,
   selfSigned: true
};



rsaKeyGen.generateCertificate(options, (err, result) => {

    if (err) {
        throw err
    }
    // Print cert artifacts to console
    console.log('%s\n\n%s', result.clientKey, result.certificate);
    console.log('%s\n\n%s', result.csr, result.serviceKey);

});

rsaKeyGen.setOpenSSLPath(path)

path custom location of openSSL path

Caveat with this method must be called in between calls to different binaries as value is cached by node's require

rsaKeyGen.setOpenSSLPath('custom/path/to/openssl');

Install rsa-gen cli

npm i rsa-key-gen -g

Todo

  • improve docs
  • improve validation of incoming parameters
0.6.1

6 years ago

0.6.0

6 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago