Algorithm-Toy-HashSC
view release on metacpan or search on metacpan
lib/Algorithm/Toy/HashSC.pm view on Meta::CPAN
# -*- Perl -*-
#
# Toy deterministic separate chain hash implementation, based on code in
# "Algorithms (4th Edition)" by Robert Sedgewick and Kevin Wayne. This
# code is not for any sort of use where performance is critical, or
# where malicious input may cause "Algorithmic Complexity Attacks" (see
# perlsec(1)).
#
# run perldoc(1) on this file for additional documentation
package Algorithm::Toy::HashSC;
use 5.010;
use strict;
use warnings;
use Carp qw/croak/;
lib/Algorithm/Toy/HashSC.pm view on Meta::CPAN
left as an exercise to the reader, probably music or artwork where the
particulars of the hash code and modulus groups the data in a desired
manner; this ordering or grouping can help determine e.g. pitch sets,
rhythmic material, etc. Hence, the B<keys_in> and B<keys_with> methods
to obtain the keys in a chain, or with a particular key. Variety could
be added by varying the modulus, or changing the B<hash> or
B<hashcode> methods.
This module is not for use where performance is a concern, or where
untrusted user input may be supplied for the key material.
L<perlsec/"Algorithmic Complexity Attacks"> discusses why Perl's hash
are no longer deterministic and thus not suitable for deterministic
music composition.
=head1 CONSTRUCTOR
The B<new> method accepts any of the L</"ATTRIBUTES">.
=head1 ATTRIBUTES
=over 4
lib/Algorithm/Toy/HashSC.pm view on Meta::CPAN
=head2 Known Issues
The default hash code calculation has not been tested to determine how
evenly it spreads keys out across the modulus space. As a workaround,
the hash key can be an object that provides a B<hashcode> method, in
which case this issue falls out of scope of this module.
=head1 SEE ALSO
L<perlsec/"Algorithmic Complexity Attacks"> - details on why Perl's hash
do not behave so simply as that of this module do.
"Algorithms" (4th Edition) by Robert Sedgewick and Kevin Wayne.
L<Hash::Util> - insight into Perl's hashes.
The "smhasher" project may help verify whether B<hashcode> functions are
as perfect as possible.
=head1 COPYRIGHT AND LICENSE
( run in 1.767 second using v1.01-cache-2.11-cpan-39bf76dae61 )