Memorable IDs
A flexible Rust library for generating human-readable, memorable identifiers. Uses combinations of adjectives, nouns, verbs, adverbs, and prepositions with optional numeric/custom suffixes.
Features
- ðŊ Human-readable - Generate IDs like
cute-rabbit,quick-owl-dance-quietly, etc - ð§ Flexible - 1-5 word components with customizable separators
- ð Predictable - Built-in collision analysis and capacity planning
- ðē Extensible - Custom suffix generators and vocabulary
- ð TypeScript - Full type safety and IntelliSense support
- ⥠Fast - ~1M IDs per second generation speed
- ðŠķ Lightweight - ~10KB vocabulary, zero dependencies
Installation
[]
= "0.1.0"
Quick Start
use ;
// Basic usage
let id = generate.unwrap;
// Output: "cute-rabbit"
// More components for uniqueness
let id = generate.unwrap;
// Output: "large-fox-swim"
// Add numeric suffix for extra capacity
let id = generate.unwrap;
// Output: "quick-mouse-042"
// Custom separator
let id = generate.unwrap;
// Output: "warm_duck"
API Reference
Core Functions
// Generate memorable ID
generate // Parse ID back to components
parse // Calculate total possible combinations
calculate_combinations // Get collision analysis
get_collision_analysis
Configuration Options
GenerateOptions
Built-in Suffix Generators
number // "042" (3-digit, Ã1,000 combinations)
number4 // "1337" (4-digit, Ã10,000 combinations)
hex // "a7" (2-digit hex, Ã256 combinations)
timestamp // "8429" (time-based, Ã10,000 combinations)
letter // "k" (single letter, Ã26 combinations)
Capacity Planning
Total Combinations by Components
| Components | Total IDs | Example |
|---|---|---|
| 1 | 87 | bright |
| 2 | 5,916 | cute-rabbit |
| 3 | 236,640 | large-fox-swim |
| 4 | 6,389,280 | happy-owl-dance-quietly |
| 5 | 166,121,280 | clever-fox-run-quickly-through |
Recommended Configurations
| Use Case | Configuration | Capacity | Example |
|---|---|---|---|
| Small apps (<1K IDs) | 2 components | 5,916 | cute-rabbit |
| Medium apps (1K-50K IDs) | 3 components | 236,640 | large-fox-swim |
| Large apps (50K-500K IDs) | 2 components + suffix | 5M+ | cute-rabbit-042 |
| Enterprise (500K+ IDs) | 4+ components + suffix | 50M+ | happy-owl-dance-042 |
Collision Probability Examples
2 components (5,916 total):
- 100 IDs: 0.84% collision chance
- 500 IDs: 19.5% collision chance
3 components (236,640 total):
- 10,000 IDs: 0.211% collision chance
- 50,000 IDs: 5.2% collision chance
2 components + 3-digit suffix (5,916,000 total):
- 100,000 IDs: 0.084% collision chance
- 1,000,000 IDs: 8.4% collision chance
Advanced Usage
Custom Suffix Generators
// Custom timestamp suffix
let id = generate.unwrap;
Parsing IDs
use parse;
let parsed = parse.unwrap;
// ParsedId {
// components: vec!["cute", "rabbit"],
// suffix: Some("042")
// }
Error Handling
use ;
match generate
Dictionary Access
use ;
let stats = get_dictionary_stats;
println!;
let dict = get_dictionary;
println!;
Examples
Web Application
use ;
// User-friendly URLs
// Unique database IDs
// Session identifiers
Batch Generation
use HashSet;
Security Notes
â ïļ Important: These IDs are NOT cryptographically secure. They use rand::rng() which is suitable for non-cryptographic purposes only.
- â Good for: User-friendly identifiers, temporary IDs, non-sensitive references
- â NOT for: Session tokens, passwords, security-critical identifiers
Contributing
Contributions welcome! Please feel free to submit a Pull Request.
Development
# Clone repository
# Run tests
# Build the library
License
This project is open-sourced software licensed under the MIT license.
Copyrights in this project are retained by their contributors. See the license file for more information.
ðĪŦ Psst! If you like my work you can support me via GitHub sponsors.