|o||computers where you cannot install Digest::MD5 (e.g. lack of a C-Compiler)|
|o||encrypting only small amounts of data (less than one million bytes). I use it to hash passwords.|
# Functional style use Digest::MD5 qw(md5 md5_hex md5_base64); $hash = md5 $data; $hash = md5_hex $data; $hash = md5_base64 $data; # OO style use Digest::MD5; $ctx = Digest::MD5->new; $ctx->add($data); $ctx->addfile(*FILE); $digest = $ctx->digest; $digest = $ctx->hexdigest; $digest = $ctx->b64digest;
This modules has the same interface as the much faster Digest::MD5. So you can easily exchange them, e.g.
The simplest way to use this library is to import the md5_hex() function (or one of its cousins):
The above example would print out the message
Digest is 6df23dc03f9b54cc38a0fc1483df6e21
provided that the implementation is working correctly. The same checksum can also be calculated in OO style:
The digest methods are destructive. That means you can only call them once and the $md5 objects is reset after use. You can make a copy with clone:
This implementation of the MD5 algorithm has some limitations:
o Its slow, very slow. Ive done my very best but Digest::MD5 is still about 100 times faster. You can only encrypt Data up to one million bytes in an acceptable time. But its very useful for encrypting small amounts of data like passwords. o You can only encrypt up to 2^32 bits = 512 MB on 32bit archs. But You should use Digest::MD5 for those amounts of data anyway.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
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 MD5 algorithm is defined in RFC 1321. The basic C code implementing the algorithm is derived from that in the RFC and is covered by the following copyright:
This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses.
o Copyright (C) 1991-1992, 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. MD5 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. MD5 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.
The original MD5 interface was written by Neil Winton (<N.Winton (at) axion.bt.co.uk>).
Thanks to Guido Flohr for his use integer-hint.
This release was made by Christian Lackas <delta (at) lackas.net>.
|perl v5.20.3||DIGEST::PERL::MD5 (3)||2013-12-13|