The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Build Status Coverage Status

NAME

Hashids - generate short hashes from numbers

SYNOPSIS

use Hashids;
my $hashids = Hashids->new('this is my salt');

# encrypt a single number
my $hash = $hashids->encode(123);          # 'YDx'
my $number = $hashids->decode('YDx');      # 123

# or a list
$hash = $hashids->encode(1, 2, 3);         # 'eGtrS8'
my @numbers = $hashids->decode('laHquq');  # (1, 2, 3)

# also get results in an arrayref
my $numbers = $hashids->decode('laHquq');  # [1, 2, 3]

DESCRIPTION

This is a port of the Hashids JavaScript library for Perl.

Hashids was designed for use in URL shortening, tracking stuff, validating accounts or making pages private (through abstraction.) Instead of showing items as 1, 2, or 3, you could show them as b9iLXiAa, EATedTBy, and Aaco9cy5. Hashes depend on your salt value.

IMPORTANT: This implementation follows the v1.0.0 API release of hashids.js. An older API of hashids.js (v0.1.4) can be found in Hashids version 0.08 and earlier releases; if you have code that depends on this API version, please use a tool like Carton to pin your Hashids install to the older version.

This implementation is also compatible with the v0.3.x hashids.js API.

METHODS

SEE ALSO

Hashids

LICENSE

Copyright (C) Zak B. Elep.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

AUTHOR

Zak B. Elep zakame@cpan.org

Original Hashids JavaScript library written by Ivan Akimov

THANKS

Props to Jofell Gallardo for pointing this excellent project to me in the first place.