![]() |
![]()
| ![]() |
![]()
NAMEDigest::Haval256 - A 5-round, 256-bit one-way hash function ABSTRACTHaval is a variable-length, variable-round one-way hash function. SYNOPSISuse Digest::Haval256; $haval = new Digest::Haval256; $haval->add(LIST); $haval->addfile(*HANDLE); $haval->reset(); $digest = $haval->digest(); $digest = $haval->hexdigest(); $digest = $haval->base64digest(); $digest = $haval->hashsize(); $digest = $haval->rounds(); DESCRIPTIONHaval is a variable-length, variable-round one-way hash function designed by Yuliang Zheng, Josef Pieprzyk, and Jennifer Seberry. The number of rounds can be 3, 4, or 5, while the hash length can be 128, 160, 192, 224, or 256 bits. Thus, there are a total of 15 different outputs. For better security, however, this module implements the 5-round, 256-bit output. Functions
EXAMPLE 1#!/usr/local/bin/perl use diagnostics; use strict; use warnings; use Digest::Haval256; my $string1 = "This is a string."; my $string2 = "This is another string."; my $string3 = "This is a string.This is another string."; my $haval = new Digest::Haval256; print "hash size=", $haval->hashsize, "\n"; print "number of rounds=", $haval->rounds, "\n\n"; $haval->add($string1); my $digest = $haval->hexdigest(); print "Hash string1 only\n"; print "$digest\n\n"; $haval->reset(); $haval->add($string1, $string2); my $digest2 = $haval->hexdigest(); print "Hash string1 and then hash string2\n"; print "$digest2\n\n"; $haval->reset(); $haval->add($string3); print "Hash the two concatenated strings\n"; my $digest3 = $haval->hexdigest(); print "$digest3\n"; EXAMPLE 2#!/usr/local/bin/perl use diagnostics; use strict; use warnings; use MIME::Base64; use Digest::Haval256; my $file = "strings.pl"; open INFILE, $file or die "$file not found"; my $haval = new Digest::Haval256; $haval->addfile(*INFILE); my $hex_output = $haval->hexdigest(); my $base64_output = $haval->base64digest(); close INFILE; print "$file\n"; print "$hex_output\n"; print "$base64_output\n"; MORE EXAMPLESSee the "examples" and "t" directories for more examples. COPYRIGHT AND LICENSECopyright 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.
|