perldoc > Digest::Perl::MD5

πŸ“– NAME

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

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ” Compute MD5 hex digest (functional)md5_hex($data)Returns MD5 hash as 32‑character hex string
πŸ” Compute MD5 base64 digest (functional)md5_base64($data)Returns MD5 hash as base64 encoded string
πŸ” Compute MD5 binary digest (functional)md5($data)Returns MD5 hash as 16‑byte binary string
πŸ” OO style: new, add, hexdigest$ctx = Digest::MD5->new; $ctx->add($data); $digest = $ctx->hexdigest;Object‑oriented interface for incremental hashing
πŸ” OO style: clone$md5->clone->hexdigestMake a copy of the digest object to compute multiple digests
πŸ” Fallback to fast C implementationeval { require Digest::MD5; import Digest::MD5 'md5_hex' }Use Digest::MD5 if available, else fall back to pure Perl

⚠️ DISCLAIMER

This is not an interface (like "Digest::MD5") but a Perl implementation of MD5. It is written in perl only and because of this it is slow but it works without C-Code. You should use "Digest::MD5" instead of this module if it is available. This module is only useful for

πŸ“‹ SYNOPSIS

# 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;

πŸ“ DESCRIPTION

This modules has the same interface as the much faster "Digest::MD5". So you can easily exchange them, e.g.

BEGIN {
  eval {
    require Digest::MD5;
    import Digest::MD5 'md5_hex'
  };
  if ($@) { # ups, no Digest::MD5
    require Digest::Perl::MD5;
    import Digest::Perl::MD5 'md5_hex'
  }
}

If the "Digest::MD5" module is available it is used and if not you take "Digest::Perl::MD5".

You can also install the Perl part of Digest::MD5 together with Digest::Perl::MD5 and use Digest::MD5 as normal, it falls back to Digest::Perl::MD5 if it cannot load its object files.

For a detailed Documentation see the "Digest::MD5" module.

πŸ’‘ EXAMPLES

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

use Digest::Perl::MD5 'md5_hex';
print 'Digest is ', md5_hex('foobarbaz'), "\n";

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:

use Digest::MD5;

$md5 = Digest::MD5->new;
$md5->add('foo', 'bar');
$md5->add('baz');
$digest = $md5->hexdigest;

print "Digest is $digest\n";

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:

$md5->clone->hexdigest

🚫 LIMITATIONS

This implementation of the MD5 algorithm has some limitations:

πŸ”— SEE ALSO

©️ COPYRIGHT

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:

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.

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

πŸ‘€ AUTHORS

Digest::Perl::MD5
πŸ“– NAME πŸš€ Quick Reference ⚠️ DISCLAIMER πŸ“‹ SYNOPSIS πŸ“ DESCRIPTION πŸ’‘ EXAMPLES 🚫 LIMITATIONS πŸ”— SEE ALSO ©️ COPYRIGHT πŸ‘€ AUTHORS

Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-09 15:02 @216.73.216.150
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!

^_top_^