- Use of the private and public key concept to secure password recovery only by the private key owner.
- Generate passwords with unlimited length.
- Randomly generate passwords.
- Password can be modified easily in advance (see examples below).
- Option for using patterns (see more details below).
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
npm i keys-to-password
yarn add keys-to-password
CommonJS
const { Password } = require("keys-to-password");
ES6
import { Password } from "keys-to-password";
const password = new Password("your-private-key");
password.setKeyboard(); // Password can contain all keyboard characters
password.generate(); // Default password-length = 12
password.getPassword(); // => '?gj39?GdA_gkf'
const publicKey = password.getPublicKey(); // save into user storage
const passwordRecover = new Password("your-private-key", publicKey);
passwordRecover.setKeyboard();
passwordRecover.generate();
passwordRecover.getPassword(); // => '?gj39?GdA_gkf'
const password = new Password("your-private-key");
password.setKeyboard();
password.generate({ passLength: 20 });
password.getPassword(); // => 'QS'-Z+8Z,:^1c%56`6h7'
const publicKey = password.getPublicKey();
const passwordRecover = new Password("your-private-key", publicKey);
passwordRecover.setKeyboard();
passwordRecover.generate({ passLength: 20 });
passwordRecover.getPassword(); // => 'QS'-Z+8Z,:^1c%56`6h7'
const password = new Password('your-private-key');
// The keyboard holds the characters from which you can generate passwords
const keyboardConfig = {
avoidChars: "1a$", // Characters 1,a,$ will not be in the generated password
isContainDigits: true,
isContainUpperCase: false, // Uppercase letters will not be in the generated password
isContainLowerCase: true,
isContainSymbols: true,
mustContainChars: "d3", // Assign d,3 characters to the keyboard
}
password.setKeyboard(keyboardConfig);
const generateConfig = {
passLength: 20,
passStartsWith: "abc", // Generated password will start with the string 'abc'
passEndsWidth: "xyz" // Generated password will end with the string 'abc'
}
password.generate(generateConfig);
password.getPassword(); // => 'abc3s:#dfs$2kl~d3xyz'
const publicKey = password.getPublicKey();
const passwordRecover = new Password("your-private-key", publicKey);
passwordRecover.setKeyboard(keyboardConfig);
passwordRecover.generate(generateConfig);
passwordRecover.getPassword(); // => 'abc3s:#dfs$2kl~d3xyz'
const password = new Password("your-private-key");
password.generateFromPattern("A_\\d{10}-PASS");
password.getPassword(); // => 'A_2563495820-PASS'
- To recover your password keep your pattern string as well as your public-key stored.
- All keyboard characters.
- \d{n} => assigns n digits to the password.
- \u{n} => assigns n uppercase letters to the password.
- \l{n} => assigns n lowercase letters to the password.
- \s{n} => assigns n symbol characters to the password.