GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Haval256(3) User Contributed Perl Documentation Haval256(3)

Digest::Haval256 - A 5-round, 256-bit one-way hash function

Haval is a variable-length, variable-round one-way hash function.

    use 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();

Haval 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.

hashsize()
Returns the size (in bits) of the hash (256, in this case)
rounds()
Returns the number of rounds used (5, 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 32-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.

    #!/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";

    #!/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";

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.

2004-08-18 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.