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


Manual Reference Pages  -  DIGEST::HAVAL256 (3)

.ds Aq ’

NAME

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

CONTENTS

ABSTRACT

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

SYNOPSIS



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



DESCRIPTION

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.

    Functions

<B>B>hashsize()<B>B> Returns the size (in bits) of the hash (256, in this case)
<B>B>rounds()<B>B> Returns the number of rounds used (5, in this case)
<B>add(LIST)B> Hashes a string or a list of strings
<B>addfile(*HANDLE)B> Hashes a file
<B>B>reset()<B>B> Re-initializes the hash state. Before calculating another digest, the hash state must be refreshed.
<B>B>digest()<B>B> Generates the hash output (a 32-byte binary string)
<B>B>hexdigest()<B>B> Generates a hexadecimal representation of the hash output
<B>B>base64digest()<B>B> Generates a base64 representation of the hash output. <B>MIME::Base64B> must be installed first for this function to work.

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

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


perl v5.20.3 HAVAL256 (3) 2004-08-18

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