The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Hashids::Util - Shuffling and conversion functions for Hashids

SYNOPSIS

    use Hashids::Util
        qw( consistent_shuffle to_alphabet from_alphabet any bignum );

DESCRIPTION

Hashids::Util provides utility functions for Hashids for consistent shuffling of alphabets, conversion of numbers to hash strings, and others. These are originally included as private functions, but are now provided here as a separate module as they can be general enough to be used in other code.

Hashids::Util does not export any functions by default.

FUNCTIONS

consistent_shuffle

    my @shuffled_alphabet = consistent_shuffle( $alphabet, $salt );

Given an alphabet and salt, produce a shuffled alphabet. Both alphabet and salt can be either strings or arrayrefs of characters.

to_alphabet

    my $hash = to_alphabet( $num, $alphabet );

Produce a hash string given a number and alphabet. The given alphabet may be a string or an arrayref of characters.

from_alphabet

    my $num = from_alphabet( $hash, $alphabet );

Produce a number from the given hash string and alphabet. The given alphabet may be a string or arrayref of characters.

any

    print "At least one non-negative value"
        if any { $_ >= 0 } @list_of_numbers;

Returns a true value if any item in the given list meets the given criterion. Returns false otherwise. Adapted from List::MoreUtils::PP.

bignum

   my $bignum = bignum( '1_152_921_504_606_846_976' );

Construct a Math::BigInt scalar from the given number.

SEE ALSO

Hashids

AUTHOR

Zak B. Elep <zakame@cpan.org>