secure-passgen

1.0.2 • Public • Published

secure passgen

A simple command-line tool that allows you to generate random and secure passwords.

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

npm install -g secure-passgen

Usage

npx secure-passgen

example

npx secure-passgen
Enter the length of the password: 50
Generated Password: s_RU0w2aPx*SzAs3Q%5EbFLL0XyGb%UkoixBL^g5XlBjkSesEv

implementation

const crypto = require("crypto")

function generateSecurePassword(n) {
  const CHARACTERS =
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+"

  const randomBytes = crypto.randomBytes(n)
  const pass = new Array(n)

  for (let i = 0; i < n; i++) {
    pass[i] = CHARACTERS[randomBytes[i] % CHARACTERS.length]
  }

  return pass.join("")
}

module.exports = { generateSecurePassword }

/secure-passgen/

    Package Sidebar

    Install

    npm i secure-passgen

    Weekly Downloads

    0

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    2.47 kB

    Total Files

    4

    Last publish

    Collaborators

    • rogedev