unique-login-credential

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.
smallLetternumber3Minimum number of lowercase letters.
numbernumber2Minimum number of digits (0-9).
specialCharacternumber2Minimum special characters.
randombooleanfalseWhether to thoroughly shuffle output.
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""Fixed string prepended to username.
lengthnumber6Total length including prefix.
Accepts all configuration options from uniquePassword
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 & Tailwind.