Easy to remember unique sentences acting as UUID
[](LICENSE) [](https://crates.io/crates/uuid-readable-rs) [](https://docs.rs/uuid-readable-rs)
Generate easy to remember sentences that acts as human readable UUIDs.
short()
or generate()
respectively)This project does not mean to be crypto safe ! Don't use this as a secure random generator.
Even if we derive sentences from UUID (that are crypto safe), there can still be some collision with 2 differents UUID but resulting in the same sentence.
25^12
possible combinations for generate()
(uses 128-bit Token)25^5
possible combinations for short()
(uses 32-bit Token)Note that the sentence generated by generate()
and the original UUID form a bijection, hence no loss of entropy.
For the long - aka generate()
- version, a typical sentence generated by this lib looks like:
Sion Mateusz Leblanc the squeezer of Savonburg regretted Joy Clemmy Marlena and 7 fiercely armadillos
Internally this correspond to:
- 12 bits for a name
- 11 bits for a name
- 14 bits for a name
- 13 bits for a personal noun
- 13 bits for a place
- 10 bits for a verb
- 12 bits for a name
- 11 bits for a name
- 14 bits for a name
- 5 bits for a number
- 6 bits for an adjective
- 7 bits for an animal
To ensure no loss of entropy, taking the example of the verb which represents 10 bits, this means that we used a list of verbs of at least 2^10 possibilities (1024).
For the short - aka short()
- version, a typical sentence looks like:
Phillips learned by 37 awkwardly swans
This correspond to:
- 6 bits for a name
- 6 bits for a verb
- 7 bits for a number
- 8 bits for an adjective
- 5 bits for an animal
Since the short version is 32 bits long and is derived from a 128-bit UUID, it is not considered as secure or as random as the long version may be. It also does not form any bijection with the original UUID.
```rust use uuid::Uuid; use uuidreadablers::{generatefrom, shortfrom, generate, short, generate_inverse};
// You can define your own UUID and pass it to uuidreadablers like so let uuid = Uuid::newv4(); let sentence128: String = generatefrom(uuid); let sentence32: String = short_from(uuid);
// You can also get an UUID from a sentence that was previously generated let originaluuid: Uuid = generateinverse(sentence128).unwrap(); asserteq!(uuid, original_uuid);
// Or let uuidreadablers handle the Uuid generation let sentence128: String = generate(); let sentence32: String = short(); ```