unique-login-credential

NPM

A robust, type-safe library to generate unique passwords and usernames.

npm install unique-login-credential

uniquePassword(options)

Generates a unique password based on the provided configuration. You can specify exactly how many of each character type you want in the final output.

PropertyTypeDefaultDescription
lengthnumber8Total length of the password.
capitalLetternumber1Minimum number of uppercase letters (A-Z).
smallLetternumber3Minimum number of lowercase letters (a-z).
numbernumber2Minimum number of digits (0-9).
specialCharacternumber2Minimum number of special characters (!@#$_*).
randombooleanfalseWhether to thoroughly shuffle the final output string.
import { uniquePassword } from 'unique-login-credential';

// Default configuration
const defaultPwd = uniquePassword();
console.log(defaultPwd);

// Custom configuration
const customPwd = uniquePassword({
  length: 12,
  capitalLetter: 2,
  specialCharacter: 1,
  random: true
});
console.log(customPwd);

uniqueUsername(options)

Combines a user-defined prefix with a randomized alphanumeric suffix according to the supplied configuration.

PropertyTypeDefaultDescription
prefixstring""The fixed string to prepend to the generated username.
lengthnumber6Total length of the username (including prefix).
Also accepts all configuration options from uniquePassword (capitalLetter, smallLetter, etc.)
import { uniqueUsername } from 'unique-login-credential';

// Using a prefix
const user1 = uniqueUsername({
  prefix: "admin_",
  length: 12,
  random: true
});
console.log(user1); // e.g. "admin_2hA9k"

Built with Nuxt & Nuxt UI.