20 Sep 2010 20:03:05 UTC
- Distribution: Data-TUID
- Module version: 0.0122
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (958 / 13 / 1)
- KwaliteeBus factor: 0
- 79.29% Coverage
- License: perl_5
- Activity24 month
- Download (4.28KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionROKR Robert Krimenand 1 contributors
- Robert Krimen
- SEE ALSO
- COPYRIGHT AND LICENSE
Data::TUID - A smaller and more communicable pseudo-UUID
use Data::TUID my $tuid = tuid # Generate a TUID of (default) length 8 $tuid = tuid length => 4 # Generate a TUID of length 4 $tuid = Data::TUID->tuid # Generate a TUID with the default length $tuid = tuid uuid => '1bf4d967-9e4c-4414-9be0-26f31c16fb53' # Generate a TUID based off of the given UUID
A sample run (length 4):
rrry ggf5 m1qb xczx pv9y
A sample run (length 8):
5xcfw8nj 2q255fyg pn3xns4k 1xcamd3y eczzca9c
A sample run (no length limit):
2kdk8wzjmfapj28cvexj6qndq7 2tmzr1f3k46tr813dtrxx2vhkqkd 1x3608c39mb1n726dhmxedjy72d pre6tg2dm37zbw9amxg2c8bghn 3ys0kw21rmtpf54gsmnd28r99pj
Data::TUID is a tool for creating small, communicable pseudo-unique identifiers. Essentially it will take a UUID, pass the result through Encode::Base32::Crockford, and resize accordingly (via
Although I've tried to sample the UUID evenly, this technique does not give any guarantee on uniqueness. Caveat emptor.
Finally, the result is more communicable (and smaller) due to the Crockford base-32 encoding. The Crockford technique uses:
A case-insensitive mapping 1 in place of '1','I', 'i', and 'L' 0 in place of '0', 'O', and 'o'
So, given a TUID (say something a user typed in for a URL), you can translate ambiguous characters (1, I, i, L, 0, 0, and o) into to 1 and 0.
The arguments are:
uuid The UUID to use as a basis for the TUID. If none is given, one will be generated for you length The length of the TUID returned. By default 8. A length of -1 will result in the whole UUID being used, and a variable length TUID being returned (somewhere between 25 to 28)
Robert Krimen <firstname.lastname@example.org>
This software is copyright (c) 2010 by Robert Krimen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.