Ted Anderson

NAME

Digest::Perl::MD4 - Perl implementation of Ron Rivests MD4 Algorithm

DISCLAIMER

This is not C-code interface (like Digest::MD5) but a Perl-only implementation of MD4 (like Digest::Perl::MD5). Because of this, it is slow but avoids platform specific complications. For efficiency you should use Digest::MD4 instead of this module if it is available.

SYNOPSIS

 # Functional style
 use Digest::Perl::MD4 qw(md4 md4_hex md4_base64);

 $hash = md4 $data;
 $hash = md4_hex $data;
 $hash = md4_base64 $data;


 # OO style
 use Digest::Perl::MD4;

 $ctx = Digest::Perl::MD4->new;

 $ctx->add($data);
 $ctx->addfile(*FILE);

 $digest = $ctx->digest;
 $digest = $ctx->hexdigest;
 $digest = $ctx->b64digest;

DESCRIPTION

This modules has the same interface as Digest::MD5. It should be compatible with the Digest::MD4 module written by Mike McCauley <mikem@open.com.au>.

EXAMPLES

The simplest way to use this library is to import the md4_hex() function (or one of its cousins):

    use Digest::Perl::MD4 'md4_hex';
    print 'Digest is ', md4_hex('foobarbaz'), "\n";

The above example would print out the message

    Digest is b2b2b528f632f554ae9cb2c02c904eeb

provided that the implementation is working correctly. The same checksum can also be calculated in OO style:

    use Digest::Perl::MD4;

    $md4 = Digest::Perl::MD4->new;
    $md4->add('foo', 'bar');
    $md4->add('baz');
    $digest = $md4->hexdigest;

    print "Digest is $digest\n";

LIMITATIONS

This implementation of the MD4 algorithm has some limitations:

  • It is slow, very slow, but still useful for encrypting small amounts of data like passwords.

  • You can only encrypt up to 2^32 bits = 512 MB on 32bit archs.

  • Digest::Perl::MD4 loads all data to encrypt into memory. This is a todo.

SEE ALSO

Digest::MD5

RFC 1320

COPYRIGHT

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Copyright 2002 Ted Anderson.
 Copyright 2000 Christian Lackas, Imperia Software Solutions.
 Copyright 1998-1999 Gisle Aas.
 Copyright 1995-1996 Neil Winton.
 Copyright 1991-1992 RSA Data Security, Inc.

The MD4 algorithm is defined in RFC 1320. The basic C code implementing the algorithm is derived from that in the RFC and is covered by the following copyright:

  • Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.

    License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing this software or this function.

    License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing the derived work.

    RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind.

    These notices must be retained in any copies of any part of this documentation and/or software.

This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses.

AUTHORS

The original MD5 interface was written by Neil Winton <N.Winton@axion.bt.co.uk>.

Digest::MD5 was made by Gisle Aas <gisle@aas.no>.

Digest::Perl::MD5 was made by Christian Lackas <delta@clackas.de>.

MD5 in 8 lines of perl5 implemented and optimized for size by John Allen[3] and collected by Adam Back[5] <adam@cypherspace.org>. Conversion to MD4 algorithm by Ted Anderson <tedanderson@mindspring.com>.

Footnotes

[3]

allen@grumman.com

[5]

http://www.cypherspace.org/~adam/