npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ealamilabs/password-generator

v1.0.2

Published

Dictionary based, easy-to-remember password generator.

Downloads

8

Readme

ealamiLabs - Password generator 🔒

npm version CI Commit Activity Known Vulnerabilities Quality Gate Status Twitter License

@ealamilabs/password-generator is a simple password generator library that can be used to generate random passwords. The library allows you to use existing dictionary 10,000+ most common English words or feed your own dictionary (or even list of words) and generate a random password based on some parameters provided.

Currently, the library supports the following parameters:

  • number of words in the password
  • separator symbol
  • random substitutions of some characters
    • a -> @ or 4
    • e -> 3
    • i -> 1
    • s -> $ or 5

Installation

If you're using npm:

npm install @ealamilabs/password-generator

If you're using yarn:

yarn add @ealamilabs/password-generator

Usage

Setting up a generator

Below you can find instructions on the basic package usage.

Setting up generator with default dictionary

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

Setting up generator with custom dictionary

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const myCustomDictionary = [
  { word: 'test', length: 4, uniqueCharacters: 3 },
  { word: 'password', length: 8, uniqueCharacters: 6 },
];

const generator = new OfflinePasswordGenerator(myCustomDictionary);

Updating dictionary on the fly

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.setDictionary([
  { word: 'test', length: 4, uniqueCharacters: 3 },
  { word: 'password', length: 8, uniqueCharacters: 6 },
]);

Generates and sets dictionary from the list of strings

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.setWords(['test', 'password']);

Adding single word

Adds the word to the dictionary.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.addWord('test');

Adding multiple words

Adds all words from the given array to the dictionary.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.addWords(['test', 'password']);

Removing single word

Removes the word from the dictionary.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.removeWord('test');

Removing multiple words

Removes all words from the given array from the dictionary.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.removeWords(['test', 'password']);

Checking if word exists

Returns true if the word exists in the dictionary, otherwise false.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();

generator.isPresent('test');

Generating passwords

Generate a password of the given length

This will generate a random password without any separators consisting of 3 random words.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();
const randomPasssword = generator.generate(3);

Generate a password of the given length with separators

This will generate a random password with given string separators between each word.

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();
const randomPasssword = generator.generate(3, '-');

Generate a password of the given length with separators and swaps

This will generate a random password with given string separators between each word. It will also randomly swap some characters in the words (e.g. a -> @ or 4, e -> 3, i -> 1, s -> $ or 5).

import { OfflinePasswordGenerator } from '@ealamilabs/password-generator';

const generator = new OfflinePasswordGenerator();
const randomPasssword = generator.generate(3, '-', true);

Roadmap

  • [ ] Add more built-in languages (currently only English, but you can extend yourself with your own dictionary)
  • [ ] Add smarter substitutions
  • [ ] Add ability to set minimum and maximum password lengths
  • [ ] Add ability to set minimum and maximum word lengths
  • [ ] Add ability to set minimum and maximum unique characters in the word
  • [ ] Add ability to use online dictionary (e.g. provided from the 10,000+ most common English words)