NAME

Integer::Tiny - Shorten and obfuscate your Integer values. Just like IDs on YouTube!

SYNOPSIS

use Integer::Tiny;
$it = Integer::Tiny->new('0WEMACKGVPHRQNST862UYZ3FL4X17O59DJIB');
print $it->encrypt('12345678');   # prints 'GQZB2'
print $it->decrypt('GQZB2');    # prints '12345678'

Check USAGE section for more cool examples.

DESCRIPTION

Do you need fast and reliable method to obfuscate and shorten some Integer values?

Do you want to choose characters range you can use in output?

This module is for you!

USAGE

Typical encrypt-and-shorten suitable for URL addresses.

my $key = 'hc2riK8fku7ezavCBJdMPwmntZ1s0yU4bOLI3SHRqANXFVD69gTG5oYQjExplW';
my $it = Integer::Tiny->new($key);
print $it->encrypt('48888851145'); # om3R4e

Time to clone someone, convert Integer to DNA sequence :)

my $key = 'GCAT';
my $it = Integer::Tiny->new($key);
print $it->encrypt('48888851145');  # ATCAGAGGGGAAAATGAC

And so on... You're limited only by your imagination when inventing keys.

This module is suitable for most Internet usage, like preventing your webpages from being scanned by ID sequence or hiding informations you do not like to show explicitly.

KEYS

Key must be a String of AT LEAST TWO UNIQUE CHARACTERS (utf8 is allowed).

Characters used in key will also be your output characters range, simple as that!

The longer the key the shorter output you get!

Here is some code snippet to generate typical alphanumeric keys.

use List::Util;
my @t = ('a' .. 'z', 'A' .. 'Z', 0 .. 9);
$key = join('', List::Util::shuffle @t );

METHODS

new

my $it = Integer::Tiny->new('qwerty');

Create new object of Integer::Tiny using key passed as the first parameter.

Carp::confess will be called on missing or invalid key.

encrypt

print $it->encrypt('48888851145'); # rtetrwqyteytyr

or

my $i = Math::BigInt->new('48888851145');
print $it->encrypt($i); # rtetrwqyteytyr

Encrypt passed Integer value (bigint allowed) using key given in constructor.

Carp::confess will be called if value to encrypt is missing or not an Integer.

WARNING: Do not use syntax shown below unless you are sure it fits in your machine integer size.

print $it->encrypt(48888851145); # integer may overflow

NOTE: Passed value is treated as Integer so leading 0 (zero) chars are ignored!

my $e = $it->encrypt('0048888851145');
print $it->decrypt($e); # 48888851145

decrypt

print $it->decrypt('rtetrwqyteytyr'); # 48888851145

Decrypt passed value using key given in constructor.

Carp::confess will be called if value to decrypt is missing or contains characters not existing in key.

PERL6

Yes, P6 Rakudo version is on the way

AUTHOR

Pawel (bbkr) Pabian

Private website: http://bbkr.org (visit for contact data)

Company website: http://implix.com

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.