Skip to content

ChristianGreinke/beautiful-username-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beautiful Username Generator

npm version

Overview

beautiful-username-generator is an elegant and lightweight Node.js library that generates random, visually pleasing usernames. This package can be utilized in any project requiring unique, catchy, and aesthetic usernames, including games, social media platforms, or online communities.

Features

  • Random Beautiful Usernames: Generates unique combinations of attributes, colors, and flowers to form aesthetic usernames.
  • Highly Configurable: Supports options like maximum username length.
  • Efficient and Lightweight: Optimized for performance, utilizing binary data files for randomized selection.
  • 18 Million+ Combinations: The generator can create 18,311,904 unique username combinations from a pool of 208 attributes, 219 colors, and 402 flowers.

Installation

To install beautiful-username-generator using npm, run:

npm install beautiful-username-generator

You can also clone the repository from GitHub:

git clone https://github.com/ChristianGreinke/beautiful-username-generator.git

Usage

Below is an example demonstrating how to use the username generator in your Node.js application:

const generator = require('beautiful-username-generator');
//const {gen} = require('beautiful-username-generator');

(async () => {
    try {
        const username = await generator.gen({ maxLength: 40 });
        //const username = await gen({ maxLength: 20 });
        console.log('Generated Username:', username);
    } catch (error) {
        console.error('Error generating username:', error);
    }
})();

Options

The gen function accepts an optional object where you can set the maximum length for the username.

Option Type Description Default Value
maxLength Number Maximum length of the generated username. Sum of attribute, color, and flower lengths (52 chars)
maxTries Number Maximum tries to generate username below maxLength. 1000

Some samples

  • BiennialMintForgetMeNot
  • FloralPatriarchAnemone
  • LoftyBisqueBletilla
  • ClusteredCoralVerbena
  • LightBoleSilverbush
  • PleasantSinopiaAster
  • GauzyQuartzAbutilon

API

generator.gen([options])

  • Description: Generates a random username like VibrantVioletOrchid.
  • Parameters:
    • options (optional): An object to customize the username generation process. Currently, it supports:
      • maxLength: Limits the length of the generated username. Note that setting a shorter maximum length will reduce the variety and uniqueness of generated usernames, as fewer character combinations will be possible, leading to lower entropy.
      • maxTries: Limits amount of tries to find a username short enough. To low maxTries and low maxLength might fail to produce a username.
  • Returns: A Promise that resolves to a string, which is the generated username.

How It Works

The username generator works by selecting random elements from three predefined binary files:

  1. Attributes: Contains 208 unique attributes.
  2. Colors: Contains 219 unique color names.
  3. Flowers: Contains 402 unique flower names.

The generator picks random entries from these binary files, decodes them, and combines them to form a unique and beautiful username. Each username consists of three parts:

  • A random attribute
  • A random color
  • A random flower

This structure ensures that usernames are both visually appealing and memorable.


Security Advice

While the beautiful-username-generator can generate millions of unique usernames, it is important to note that usernames alone should not be relied upon for security purposes. A username generated by this library should be used in combination with a strong, random password to ensure adequate security.

This approach is similar to the security of using email addresses or handpicked usernames, where the username alone is not the main factor in security but instead the strength of the password is critical.


File Structure

  • api/generator.js: Main logic for the username generation.
  • api/flattenedAttributes_15.bin: Binary file storing random attributes.
  • api/flattenedColors_15.bin: Binary file storing random color names.
  • api/flattenedFlowers_22.bin: Binary file storing random flower names.

The generator pulls data from these binary files to construct usernames dynamically.


Contributing

Contributions are welcome! If you encounter any bugs or have ideas for improvement, please submit an issue or a pull request to the GitHub repository.

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -am 'Add a new feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. Create a new Pull Request

License

This project is licensed under the MIT License. See the LICENSE file for details.


Bugs & Issues

If you find a bug or have issues using the package, please submit them to the Issues page on GitHub.


Author

Created and maintained by Christian Greinke. You can find more of my work on my GitHub.


Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published