logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

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

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>  (I  took  his  Interface  and  part  of  the
       documentation).

       Thanks to Guido Flohr for his 'use integer'-hint.

       This release was made by Christian Lackas <delta (at) lackas.net>.

perl v5.36.0                                       2022-10-13                             Digest::Perl::MD5(3pm)

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.

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

       •   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). I use it to hash passwords.

       •   educational purposes

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:

       •   It's  slow,  very  slow. I've 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  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::MD5" for
           those amounts of data anyway.

Name

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

See Also

       Digest::MD5

       md5(1)

       RFC 1321

       tools/md5: a small BSD compatible md5 tool written in pure perl.

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;

See Also