Random-Pass-Package
This is package which lets you generate random passwords with options like, length and should it contain: numbers / letters / speacial chars.
Installation and Importing
- Install the package
npm i @shreyazz/random_pass
- Import package
const randomPass = require("@shreyazz/random_pass");
or
import randomPass from "@shreyazz/random_pass";
Functions
There are two functions in the package. (Here I'm assuming that the package is imported in randomPass
variable)
- .info()
- .generateRandomPass()
-
randomPass.info() It console logs the information about the package and how to use it.
-
randomPass.generateRandomPass() This function takes one parameter, an object. That object contains two properties. Length (Length of the password) and shouldContain (array of things you want to include in the password like, numbers or special chars)
const password = randomPass.generateRandomPass({ length: 10, shouldContain: ["numbers", "letters", "spl-chars"], });
Stuff to know before usage.
-
shouldContain
array must have at least two options. - To include:
- Letters:
letters
- Numbers:
numbers
, - Speacial Characters:
spl-chars
- Letters:
Example: If I want to include only Numbers and Special Characters
const password = randomPass.generateRandomPass({
length: 5,
shouldContain: ["numbers", "spl-chars"],
});
Made with