NAME
Digest::Whirlpool - A 512-bit one-way hash function
ABSTRACT
Digest::Whirlpool - A 512-bit, collision-resistant, one-way hash function developed by Paulo S. L. M. Barreto and Vincent Rijmen.
SYNOPSIS
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();
DESCRIPTION
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.
Functions
- hashsize()
-
Returns the size (in bytes) of the hash (64, in this case)
- add(LIST)
-
Hashes a string or a list of strings
- addfile(*HANDLE)
-
Hashes a file
- reset()
-
Re-initializes the hash state. Before calculating another digest, the hash state must be refreshed.
- digest()
-
Generates the hash output (a 64-byte binary string)
- hexdigest()
-
Generates a hexadecimal representation of the hash output
- base64digest()
-
Generates a base64 representation of the hash output. MIME::Base64 must be installed first for this function to work.
EXAMPLE 1
#!/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";
EXAMPLE 2
#!/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";
MORE EXAMPLES
See the "examples" and "t" directories for more examples.
COPYRIGHT AND LICENSE
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.