@luca-pal/password-utilities
v1.0.2
Published
A small Javascript library for password generation
Downloads
28
Maintainers
Readme
@lucap/password-utilities
A lightweight JavaScript utility library for generating strong passwords and validating password strength.
This package helps developers quickly create secure passwords and verify whether a password meets common security requirements.
Installation
Using npm
npm install @yourname/password-utilitiesUsing yarn
yarn add @yourname/password-utilitiesUsage
Import the functions:
import {
generateStrongPassword,
isStrongPassword
} from "@yourname/password-utilities";generateStrongPassword(length)
Generates a random password using uppercase letters, lowercase letters, numbers, and special characters.
Parameters
length(number): The desired length of the generated password. Default value is12.
Returns
- A randomly generated password string with the specified length.
Example
generateStrongPassword(1);
// Example output: "W"generateStrongPassword(12);
// Example output: "pC%mD8TpCKn2"isStrongPassword(password)
Checks whether a password satisfies common security requirements.
A strong password must contain:
- At least 8 characters
- One uppercase letter
- One lowercase letter
- One number
- One special character
Parameters
password(string): The password to validate.
Returns
trueif the password is strongfalseotherwise
Example
isStrongPassword("Hello World");
// falseisStrongPassword("pC%mD8TpCKn2");
// trueContributing
Contributions are welcome!
If you would like to contribute to this project, please follow these steps:
- Fork the repository
- Create a new branch for your feature or bug fix
git checkout -b feature-name- Make your changes and commit them
git commit -m "Describe your changes"- Push your branch to your fork
git push origin feature-name- Open a Pull Request and describe your changes clearly
For more details, please read CONTRIBUTING.md.
License
This project is licensed under the MIT License.
See LICENSE.md for full licensing information.
