@nfi/openssl-cmd
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

@nfi/openssl-cmd

npm version pipeline status coverage status standard-js

Basic wrapper for the OpenSSL command-line utility.

Installation

npm install @nfi/openssl-cmd

Usage Example

const { openssl } = require('@nfi/openssl-cmd')

/**
 * Generate a new RSA private key.
 * @param {number} [bits] Optional key size; default 2048.
 * @param {string} [pass] Optional passphrase; unencrypted by default.
 * @returns {Promise<Buffer>} PEM-formatted private key.
*/
async function genpkey(bits, pass) {
  return (await openssl('genpkey')
    .args('-algorithm', 'rsa')
    .argsIf(bits, '-pkeyopt', `rsa_keygen_bits:${bits}`)
    .argsIf(pass, '-pass', `pass:${pass}`, '-aes256')
    .exec()
  ).stdout
}

Package Sidebar

Install

npm i @nfi/openssl-cmd

Weekly Downloads

0

Version

2.0.2

License

ISC

Unpacked Size

10 kB

Total Files

6

Last publish

Collaborators

  • cptpackrat