Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
generate-passphrase
Advanced tools
✨Zero dependency module for generating passphrase.
The code is close to node generate-password repo. But this is for a passphrase, with English language.
ProtonMail has a decent article explaining about password vs passphrase.
Is this secure? Yes. I don't use Math.floor
, I used the crypto
module.
Why is this repo heavy? I'm using sindresorhus' word-list repo for fetching the English word list. If you have a better idea/workaround for this, feel free to open up an issue and file a PR! I'll gladly accept any feedbacks.
$ npm install generate-passphrase
# or
$ yarn add generate-passphrase
# or basically any package manager you like.
import { generate, generateMultiple } from 'generate-passphrase'
// or
const { generate, generateMultiple } = require('generate-passphrase')
const passphrase = generate();
// 'provoke-goddesshoods-26-staghorns'
const anotherPassphrase = generate({ length: 3, separator: '.', titlecase: true })
// see available options below
const multiplePassphrase = generateMultiple(3)
// ['pinocytotically-loricated-prithee-hypnotizer', 'sambaing-phenotypically-singlesticks-239', ... ]
const anotherMultiplePassphrase = generateMultiple(10, { length: 2, uppercase: true, numbers: false })
I know some of us need to generate it fast just for the sake of it, you can add fast
as a parameter. (It defaults to false). Please bear in mind, this would make the returning random passphrase not cryptographically secure
const fast = generate({ fast: true })
// cultivars-strigose-avisements-58
const extraFast = generateMultiple(5, { fast: true })
// ['extrorsal-169-resultlessness-168', 'postmodern-kolkhozniki-skulkers-99', ... ]
Key | Type | Default |
---|---|---|
length | integer | 4 |
separator | string | '-' |
numbers | boolean | true |
uppercase | boolean | false |
titlecase | boolean | false |
pattern | string | null |
fast | boolean | false |
A few things to note:
true
, it will be words full of uppercase.TL;DR: It's slow. On v1.1.0, I managed to get the algorithm runs a lot faster. There is also an additional fast
option if you're just aiming for the speed.
I'm using:
Benchmark for single passphrase/password:
Module | Ops/sec | Accuracy | Runs sampled |
---|---|---|---|
generate-passphrase | 117,546 | ±2.32% | 385 |
generate-passphrase (fast enabled) | 653,668 | ±1.07% | 444 |
generate-password | 434,495 | ±1.49% | 332 |
niceware | 207,719 | ±5.79% | 232 |
randomatic | 8,026 | ±2.23% | 319 |
Benchmark for multiple passphrase/password (generateMultiple
function):
Module | Ops/sec | Accuracy | Runs sampled |
---|---|---|---|
generate-passphrase | 12,338 | ±1.80% | 407 |
generate-passphrase (fast enabled) | 64,124 | ±1.51% | 441 |
generate-password | 43,775 | ±2.15% | 317 |
Yes please.
FAQs
Zero dependency module - Secure random passphrase
We found that generate-passphrase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.