# secure-passgen

> secure password generator (CLI + library)

Latest version **1.1.0** (published 2026-06-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install secure-passgen
pnpm add secure-passgen
yarn add secure-passgen
bun add secure-passgen
```

Provides the command `secure-passgen`.

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2026-06-30 |
| First published | 2023-12-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rogedev |
| Maintainers | rogedev |
| Keywords | cli, cli-tool, javascript, typescript, esm, library, password, password-generator, security |

## Links

- npm: https://www.npmjs.com/package/secure-passgen
- Repository: https://github.com/rogedev/secure-passgen
- Homepage: https://github.com/rogedev/secure-passgen#readme
- Issues: https://github.com/rogedev/secure-passgen/issues
- npm.io page: https://npm.io/package/secure-passgen

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2026-06-30
- 1.0.2 — 2023-12-13
- 1.0.1 — 2023-12-12
- 1.0.0 — 2023-12-12

## README

# secure passgen

A simple tool to generate random and secure passwords. Use it from the
command line or import it as a library in your own JavaScript/TypeScript app.
This app is used as an example about how to publish packages in npm.

## Installation

This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).

Before installing, [download and install Node.js](https://nodejs.org/en/download/).

```console
npm install -g secure-passgen
```

## Usage

Run it interactively (press Enter to use the default length of 16):

```console
npx secure-passgen
```

Or pass the length directly with the `--length` flag (alias `-l`):

```console
npx secure-passgen --length 20
```

## example

```console
npx secure-passgen --length 50
Generated Password: s_RU0w2aPx*SzAs3Q%5EbFLL0XyGb%UkoixBL^g5XlBjkSesEv
```

```console
npx secure-passgen
Enter the length of the password (default 16):
Generated Password: (pw0XFiS3nHjzI(r
```

## Use as a library

Install it as a dependency:

```console
npm install secure-passgen
```

The package ships both ESM and CommonJS builds plus TypeScript types, so you
can `import` or `require` it.

### ESM / TypeScript

```js
import newPassword, { generatePassword } from "secure-passgen"

const password = newPassword()       // 16 characters by default
const longer = generatePassword(32)  // pass a custom length
```

### CommonJS

```js
const newPassword = require("secure-passgen")

const password = newPassword()
const longer = newPassword(32)
```

### API

`generatePassword(length?: number): string`

- `length` — number of characters (default `16`). Must be a positive integer;
  otherwise a `TypeError` (non-integer) or `RangeError` (less than 1) is thrown.
- The default export is the same function, so `import newPassword from "secure-passgen"`
  and `import { generatePassword } from "secure-passgen"` are interchangeable.

Characters are drawn uniformly from `a-z A-Z 0-9 !@#$%^&*()-_=+` using
`crypto.randomInt`, which uses rejection sampling to avoid modulo bias.

---
_Source: https://npm.io/package/secure-passgen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
