The Unique Login Credential Generator is an npm package that creates customizable usernames and passwords with options for length, character types, and randomization. It's designed for secure and unique user authentication.
APACHE-2.0 License
unique-login-credential
is a versatile Node.js package designed to generate secure and customizable passwords and usernames. It allows you to specify various parameters to tailor the generated credentials to your specific needs. Whether you're building a new application or enhancing an existing one, this package provides an easy-to-use solution for credential generation.
To install the package, use npm:
npm install unique-login-credential
If your project uses ES modules, you can import the functions using import
statements:
import { uniquePassword, uniqueUsername } from 'unique-login-credential';
// Generate a password with specific options
const password = uniquePassword({
length: 12,
capitalLetter: 2,
smallLetter: 4,
number: 3,
specialCharacter: 2,
random: true
});
console.log(`Generated Password: ${password}`);
// Generate a username with specific options
const username = uniqueUsername({
prefix: 'user_',
length: 10,
capitalLetter: 2,
smallLetter: 5,
number: 2,
specialCharacter: 1,
random: true
});
console.log(`Generated Username: ${username}`);
For projects using CommonJS modules, import the functions using require
:
const { uniquePassword, uniqueUsername } = require('unique-login-credential');
// Generate a password with specific options
const password = uniquePassword({
length: 12,
capitalLetter: 2,
smallLetter: 4,
number: 3,
specialCharacter: 2,
random: true
});
console.log(`Generated Password: ${password}`);
// Generate a username with specific options
const username = uniqueUsername({
prefix: 'user_',
length: 10,
capitalLetter: 2,
smallLetter: 5,
number: 2,
specialCharacter: 1,
random: true
});
console.log(`Generated Username: ${username}`);
Generates a unique and secure password based on the provided options.
Parameters:
options
: An object with the following properties:
length
(number): Total length of the password. The minimum value should be the sum of capitalLetter
, smallLetter
, number
, and specialCharacter
. Default: 8capitalLetter
(number): Number of capital letters to include. Default: 1smallLetter
(number): Number of small letters to include. Default: 3number
(number): Number of numeric digits to include. Default: 2specialCharacter
(number): Number of special characters to include. Default: 2random
(boolean): Whether to shuffle the characters in the password randomly. Default: falseReturns: A randomly generated password as a string.
Example:
const password = uniquePassword({
length: 12,
capitalLetter: 2,
smallLetter: 4,
number: 3,
specialCharacter: 2,
random: true
});
console.log(password); // Example output: "A1b@C2d!Ef3G"
Generates a unique username based on the provided options.
Parameters:
options
: An object with the following properties:
prefix
(string): A prefix to add at the beginning of the username. Default: ""length
(number): Total length of the username, including the prefix. The minimum length should be the sum of capitalLetter
, smallLetter
, number
, specialCharacter
, and the length of the prefix. Default: 6capitalLetter
(number): Number of capital letters to include. Default: 1smallLetter
(number): Number of small letters to include. Default: 3number
(number): Number of numeric digits to include. Default: 2specialCharacter
(number): Number of special characters to include. Default: 0random
(boolean): Whether to shuffle the characters in the username randomly. Default: falseReturns: A randomly generated username as a string.
Example:
const username = uniqueUsername({
prefix: 'user_',
length: 10,
capitalLetter: 2,
smallLetter: 5,
number: 2,
specialCharacter: 1,
random: true
});
console.log(username); // Example output: "user_a1B2cD@"
Contributions are welcome! To contribute:
git checkout -b feature/your-feature
).git commit -am 'Add new feature'
).git push origin feature/your-feature
).This project is licensed under the Apache 2.0 License. See the LICENSE file for details.