Digest::Perl::MD5(3)
π Digest::Perl::MD5(3) β yeah that's the perldoc one, bestie
okay so real talk: this is the User Contributed Perl Documentation page for Digest::Perl::MD5, and we're gonna go through the whole thing together, no skips, no cap. π«Ά
β¨ NAME β¨
Digest::MD5::Perl β a pure-Perl implementation of Ron Rivest's MD5 Algorithm. π
π DISCLAIMER π
bestie. listen to me. π«Ά This is not an interface (like Digest::MD5) β it's an actual Perl implementation of MD5. It's written in perl only, and because of that it is slow but it works without C-Code. If Digest::MD5 is available you should use Digest::MD5 instead of this module, periodt.
So like, when is this module actually useful? Only for:
- computers where you cannot install
Digest::MD5(e.g. lack of a C-Compiler) π - encrypting only small amounts of data (less than one million bytes). The author uses it to hash passwords. π₯
- educational purposes π
πΈ SYNOPSIS πΈ
functional style, my beloved:
# Functional style
use Digest::MD5 qw(md5 md5_hex md5_base64);
$hash = md5 $data;
$hash = md5_hex $data;
$hash = md5_base64 $data;
and then the OO glow-up:
# 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 module has the same interface as the much faster Digest::MD5. So you can easily exchange them, like:
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'
}
}
the way that works is: if the Digest::MD5 module is available it is used, and if not you take Digest::Perl::MD5. iconic fallback behaviour honestly. π
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. slay. β¨
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";
π¨ okay IMPORTANT: the digest methods are destructive. That means you can only call them once and the$md5object is reset after use. You can make a copy withclone:
$md5->clone->hexdigest
clone before you hexdigest, iykyk. π
π LIMITATIONS π
This implementation of the MD5 algorithm has some limitations, and I'm gonna be so fr with you:
- It's slow, very slow. The author has done their very best but
Digest::MD5is still about 100 times faster. You can only encrypt Data up to one million bytes in an acceptable time. But it's very useful for encrypting small amounts of data like passwords. π - You can only encrypt up to 2^32 bits = 512 MB on 32bit archs. But You should use
Digest::MD5for those amounts of data anyway. π
π SEE ALSO π
go read those, bestie. π
π 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:
- 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.
This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses.
π like, keep the notices in your copies, okay? that's the whole vibe. don't be that person.
π§ AUTHORS π§
The original MD5 interface was written by Neil Winton (<N.Winton (at) axion.bt.co.uk>). π«Ά
Digest::MD5 was made by Gisle Aas <gisle (at) aas.no> (the interface and part of the documentation were taken from there).
Thanks to Guido Flohr for his 'use integer'-hint. β
This release was made by Christian Lackas <delta (at) lackas.net>.
and that's the whole page!! π¦ this doc shipped with perl v5.42.0, dated 2025-02-06 β so go forth, hash responsibly, and remember: if you can use the C one, use the C one. mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Digest-Perl-MD5 1.900.0-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms