beautiful-username-generator
v1.0.2
Published
Generate random beuatiful usernames
Downloads
516
Readme
Beautiful Username Generator
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 |
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:
- Attributes: Contains 208 unique attributes.
- Colors: Contains 219 unique color names.
- 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.
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -am 'Add a new feature'
) - Push to the branch (
git push origin feature/your-feature
) - 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.