Digest::Whirlpool - A 512-bit one-way hash function
Digest::Whirlpool - A 512-bit, collision-resistant, one-way hash function developed by Paulo S. L. M. Barreto and Vincent Rijmen.
use Digest::Whirlpool; $whirlpool = new Digest::Whirlpool; $whirlpool->add(LIST); $whirlpool->addfile(*HANDLE); $whirlpool->reset(); $digest = $whirlpool->digest(); $digest = $whirlpool->hexdigest(); $digest = $whirlpool->base64digest(); $digest = $whirlpool->hashsize();
Whirlpool is a 512-bit, collision-resistant, one-way hash function designed by Paulo S. L. M. Barreto and Vincent Rijmen. Whirlpool is the NESSIE winner for this category.
Returns the size (in bits) of the hash (512, in this case)
Hashes a string or a list of strings
Hashes a file
Re-initializes the hash state. Before calculating another digest, the hash state must be refreshed.
Generates the hash output (a 64-byte binary string)
Generates a hexadecimal representation of the hash output
Generates a base64 representation of the hash output. MIME::Base64 must be installed first for this function to work.
#!/usr/local/bin/perl use diagnostics; use strict; use warnings; use Digest::Whirlpool; my $string1 = "This is a string."; my $string2 = "This is another string."; my $string3 = "This is a string.This is another string."; my $whirlpool = new Digest::Whirlpool; print "hash size=", $whirlpool->hashsize, "\n"; $whirlpool->add($string1); my $digest = $whirlpool->hexdigest(); print "Hash string1 only\n"; print "$digest\n\n"; $whirlpool->reset(); $whirlpool->add($string1, $string2); my $digest2 = $whirlpool->hexdigest(); print "Hash string1 and then hash string2\n"; print "$digest2\n\n"; $whirlpool->reset(); $whirlpool->add($string3); print "Hash the two concatenated strings\n"; my $digest3 = $whirlpool->hexdigest(); print "$digest3\n";
#!/usr/local/bin/perl use diagnostics; use strict; use warnings; use MIME::Base64; use Digest::Whirlpool; my $file = "strings.pl"; open INFILE, $file or die "$file not found"; my $whirlpool = new Digest::Whirlpool; $whirlpool->addfile(*INFILE); my $hex_output = $whirlpool->hexdigest(); my $base64_output = $whirlpool->base64digest(); close INFILE; print "$file\n"; print "$hex_output\n"; print "$base64_output\n";
See the "examples" and "t" directories for more examples.
Copyright 2003 by Julius C. Duque <jcduque (AT) lycos (DOT) com>
This library is free software; you can redistribute it and/or modify it under the same terms as the GNU General Public License.
To install Digest::Whirlpool, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Digest::Whirlpool
CPAN shell
perl -MCPAN -e shell install Digest::Whirlpool
For more information on module installation, please visit the detailed CPAN module installation guide.