New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

password-generator-js

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

password-generator-js

A password generator for both node and browsers

  • 2.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59
decreased by-25.32%
Maintainers
1
Weekly downloads
 
Created
Source

Password Generator

A random password generator for node and browsers, which makes it possible to choose random-function. It either creates passwords using combinations of characters, digits and symbols, or from words (english or spanish currently).

Installation

npm install password-generator-js

Usage

Node.js

const PasswordGenerator = require('password-generator-js')
let password = PasswordGenerator.generatePassword([options, [randomFunction]])

Browser

<script src="path/to/module/index.js"></script>
let password = PasswordGenerator.generatePassword([options, [randomFunction]])

API

Synchronous
password = PasswordGenerator.generatePassword([options, [randomFunction]])

It is possible to specifiy random function. The function should take no arguments and return a value between 0 and 1.

Asynchronous
password = PasswordGenerator.generatePassword(options, randomFunction[, callback])

password = PasswordGenerator.generatePassword({ length: 20 }, c => {
    let RandomOrg = require('random-org')
    let random = new RandomOrg({ apiKey: '12345-67890-api-key' })
    random.generateDecimalFractions()
        .then(result => {
            c(result.random.data[0])
        });
}).then(console.log.bind(console))

password = PasswordGenerator.generatePassword({ length: 20 }, () => {
    let RandomOrg = require('random-org')
    let random = new RandomOrg({ apiKey: '12345-67890-api-key' })
    return random.generateDecimalFractions()
        .then(result => result.random.data[0]);
}).then(console.log.bind(console))

The random function should take a callback as argument and call it with the result or take no argument and return a promise which resolves with the result.

Options
{
    length: 25,
    uppercase: true,
    lowercase: true,
    digits: true,
    symbols: true,
    obscureSymbols: true,
    extra: ''
}

Extra symbols can be used to add possible characters to the algorithm.

Static
password = PasswordGenerator.generatePassword([options, [randomFunction]])
password = PasswordGenerator.generatePassword(options, randomFunction[, callback])
    .then(callback)
Object oriented
let passwordGenerator = new PasswordGenerator([options, [randomFunction]])

passwordGenerator.options = { ... }
passwordGenerator.random = () => { ... }

password = passwordGenerator.generatePassword([options, [randomFunction]])
password = passwordGenerator.generatePassword(options, [randomFunction[, callback]])
    .then(callback)
Words

Both english and spanish is currently available

Node.js
password = PasswordGenerator.generatePasswordFromWords([length[, language]])

Language is specified as a string such as 'english' or 'spanish'.

Browser
<script src="path/to/module/words/english.js"></script>
<script src="path/to/module/words/spanish.js"></script>
password = PasswordGenerator.generatePasswordFromWords([length[, language]])

Language is specified as a string such as 'english' or 'spanish'.

Keywords

FAQs

Package last updated on 22 Mar 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc