p-gen
A customizable javascript password generator.
How to use
In the browser
Insert the p-gen.js file in the html
Download the p-gen.js file from HERE
<script src="./p-gen.js"></script>
or
Insert it directly from gtihub
<script defer src="https://raw.githubusercontent.com/AM-77/p-gen/master/p-gen.js"></script>
Use it
// create an instance of pGen Class
let pgen = new pGen()
// use the instance to access the pGen methods
let password = pgen.generatePassword(true, true, true, true, 12)
In node
Install the p-gen module
npm i @am-77/p-gen
or
yarn add @am-77/p-gen
Use it
const pGen = require("@am-77/p-gen")
let pgen = new pGen()
let password = pgen.generatePassword(true, true, true, true, 12)
Available Methods
-
generatePassword(lowercase:optional = true, uppercase:optional = true, numbers:optional = true, symbols:optional = true, length:optional = 12)
- lowercase : set it to
true
if the password should contains lowercase orfalse
otherwise,true
by default. - uppercase : set it to
true
if the password should contains uppercase orfalse
otherwise,true
by default. - numbers : set it to
true
if the password should contains numbers orfalse
otherwise,true
by default. - symbols : set it to
true
if the password should contains symbols orfalse
otherwise,true
by default. - length : the length of the password equals 12 by default
- lowercase : set it to
-
generatePasswordWithChars(chars, length:optional = 12)
- chars : a string of the characters that must be used to generate the password.
- length : the length of the password equals 12 by default
-
generateLowercase(length)
-
generateUppercase(length)
-
generateNumbers(length)
-
generateSymbols(length)
Demo
You can check the live demo here : p-gen Demo
Contribution
Feel free to raise an issue or submit a pull request.
Copyright and license
Code copyright 2019 AM-77. Code released under the MIT license.