0.1.1 • Published 5 years ago
ynw-secure-password v0.1.1
YnwSecurePassword
A JavaScript secure password library for generating and validating a secure password with multiple configurations
Example
Live demo: https://ynw-team.github.io/YnwSecurePasswordDemo
Code: https://github.com/YNW-Team/YnwSecurePasswordDemo
Features
- ✨ Generate secure password:
- Using default configuration
- Using default configuration with customized length
- Using customized configuration of character set and length
- ✅ Checking conformity of password with pre-defined configuration:
- Using default configuration
- Using default configuration with customized length
- Using customized configuration of character set and length
Installation
Install using NPM:
npm install ynw-secure-password
Install using YARN:
yarn add ynw-secure-password
Usage
Generator
Using:
Example code:
import YnwSecurePassword from 'ynw-secure-password';
// generator without arg, it will use default config
const password_without_arg = YnwSecurePassword.generator();
console.log(password_without_arg);
// generator with length (must be equal 0 or great than or equal 4), it will use default config
const password_with_length = YnwSecurePassword.generator(10);
console.log(password_with_length);
// generator with config (must be validated), it will use default config
const config = {
length: 15,
rules: [
{
chars: 'abcde',
},
{
chars: '01234',
min: 1,
},
{
chars: 'AZERTY',
min: 2,
},
],
};
const password_with_config = YnwSecurePassword.generator(config);
console.log(password_with_config);
Validator
Using:
Example code
import YnwSecurePassword from 'ynw-secure-password';
// generator without arg, it will use default config
const password_without_arg = YnwSecurePassword.validator('Ynw-Secure-Password-2021');
console.log(password_without_arg.isValid);
// generator with length (must be great thanor equal 4), it will use default config
const password_with_length = YnwSecurePassword.generator('Ynw-Secure-Password-2021', 10);
console.log(password_with_length.isValid);
// generator with config (must be validated), it will use default config
const config = {
length: 15,
rules: [
{
chars: 'abcde',
},
{
chars: '01234',
min: 1,
},
{
chars: 'AZERTY',
min: 2,
},
],
};
const password_with_config = YnwSecurePassword.validator('Ynw-Secure-Password-2021', config);
console.log(password_with_config.isValid);
API
Interfaces
Interface ConfigI
Interface CharacterRuleI
Interface ResultValidatorI
Constants MATH
const INFINITY
Constants CHARACTERS
const ALPHABET_UPPER_CASE
const ALPHABET_LOWER_CASE
const SPECIAL
const DIGITS
const ALPHABET_UPPER_LOWER_CASE
const ALPHABET_NUMBERS
const ALL
Constants CONFIG
const DEFAULT_CONFIG
const ALL_CHARACTER_CONFIG
const ONLY_ALPHABET_CONFIG
const ALPHABET_NUMBERS_CONFIG
License
YnwSecurePassword is freely distributable under the terms of the MIT license.