473 lines
11 KiB
HTML
473 lines
11 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>GT::MD5 - Perl implementation of Ron Rivests MD5 Algorithm</title>
|
|
<link rev="made" href="mailto:root@penguin.office.gossamer-threads.com" />
|
|
|
|
<style type="text/css">
|
|
/* $MVD$:fontset("Untitled Font Set 1","ARIEL","HELVETICA","HELV","SANSERIF") */
|
|
/* $MVD$:fontset("Arial","Arial") */
|
|
/* $MVD$:fontset("Arial Black","Arial Black") */
|
|
/* $MVD$:fontset("Algerian","Algerian") */
|
|
|
|
|
|
body {
|
|
background-color: white;
|
|
font-family: Verdana, Arial, sans-serif;
|
|
font-size: small;
|
|
color: black;
|
|
}
|
|
|
|
|
|
p {
|
|
background-color : white;
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
h1 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : bold;
|
|
font-size : medium;
|
|
background-color : white;
|
|
color : maroon;
|
|
}
|
|
|
|
|
|
h2 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : medium;
|
|
font-weight : bold;
|
|
color : blue;
|
|
background-color : white;
|
|
}
|
|
|
|
|
|
h3 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : bold;
|
|
font-size : medium;
|
|
color : black;
|
|
background-color : white;
|
|
}
|
|
|
|
|
|
h4 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : bold;
|
|
font-size : small;
|
|
color : maroon;
|
|
background-color : white;
|
|
}
|
|
|
|
|
|
h5 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : bold;
|
|
font-size : small;
|
|
color : blue;
|
|
background-color : white;
|
|
}
|
|
|
|
|
|
h6 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : bold;
|
|
font-size : small;
|
|
color : black;
|
|
background-color : white;
|
|
}
|
|
|
|
|
|
ul {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
ol {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
dl {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
li {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
th {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
td {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
dl {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
dd {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
dt {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
code {
|
|
font-family : Courier;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
|
|
pre {
|
|
font-family : Courier;
|
|
font-size : small;
|
|
color : black;
|
|
}
|
|
|
|
.mvd-H1 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : bold;
|
|
font-size : 14.0pt;
|
|
background-color : transparent;
|
|
background-image : none;
|
|
color : maroon;
|
|
}
|
|
|
|
|
|
.mvd-H2 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : 12.0pt;
|
|
color : blue;
|
|
}
|
|
|
|
|
|
p.indent {
|
|
font-family : "Verdana, Arial, sans-serif";
|
|
list-style-type : circle;
|
|
list-style-position : inside;
|
|
color : black;
|
|
margin-left : 16.0pt;
|
|
}
|
|
|
|
|
|
.mvd-P-indent {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
list-style-type : circle;
|
|
list-style-position : inside;
|
|
color : black;
|
|
margin-left : 16.0pt;
|
|
}
|
|
|
|
|
|
pre.programlisting {
|
|
font-size : 9.0pt;
|
|
list-style-type : disc;
|
|
margin-left : 16.0pt;
|
|
margin-top : -14.0pt;
|
|
}
|
|
|
|
|
|
.mvd-PRE-programlisting {
|
|
font-size : 9.0pt;
|
|
list-style-type : disc;
|
|
margin-left : 16.0pt;
|
|
margin-top : -14.0pt;
|
|
}
|
|
|
|
|
|
.mvd-PRE {
|
|
font-size : 9.0pt;
|
|
}
|
|
|
|
|
|
p.note {
|
|
margin-left : 28.0pt;
|
|
}
|
|
|
|
|
|
.mvd-P-note {
|
|
margin-left : 28.0pt;
|
|
}
|
|
|
|
|
|
.mvd-H4 {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-weight : normal;
|
|
font-size : 9.0pt;
|
|
color : black;
|
|
margin-left : 6.0pt;
|
|
margin-top : -14.0pt;
|
|
}
|
|
|
|
|
|
.mvd-P {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
font-size : 10.0pt;
|
|
color : black;
|
|
}
|
|
|
|
.mvd-BODY {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
background-color : white;
|
|
}
|
|
|
|
|
|
p.indentnobullet {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
list-style-type : none;
|
|
}
|
|
|
|
|
|
.mvd-P-indentnobullet {
|
|
font-family : Verdana, Arial, sans-serif;
|
|
list-style-type : none;
|
|
}
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body style="background-color: white">
|
|
|
|
<p><a name="__index__"></a></p>
|
|
<!-- INDEX BEGIN -->
|
|
|
|
<ul>
|
|
|
|
<li><a href="#name">NAME</a></li>
|
|
<li><a href="#disclaimer">DISCLAIMER</a></li>
|
|
<li><a href="#synopsis">SYNOPSIS</a></li>
|
|
<li><a href="#description">DESCRIPTION</a></li>
|
|
<li><a href="#examples">EXAMPLES</a></li>
|
|
<li><a href="#limitations">LIMITATIONS</a></li>
|
|
<li><a href="#see_also">SEE ALSO</a></li>
|
|
<li><a href="#copyright">COPYRIGHT</a></li>
|
|
<li><a href="#authors">AUTHORS</a></li>
|
|
</ul>
|
|
<!-- INDEX END -->
|
|
|
|
<hr />
|
|
<p>
|
|
</p>
|
|
<h1><a name="name">NAME</a></h1>
|
|
<p>GT::MD5 - Perl implementation of Ron Rivests MD5 Algorithm</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="disclaimer">DISCLAIMER</a></h1>
|
|
<p>Majority of this module's code is borrowed from Digest::Perl::MD5 (Version 1.8).</p>
|
|
<p>This is <strong>not</strong> an interface (like <code>Digest::MD5</code>) 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 <code>Digest::MD5</code> instead of this module if it is available.
|
|
This module is only usefull for</p>
|
|
<dl>
|
|
<dt></dt>
|
|
<dd>
|
|
computers where you cannot install <code>Digest::MD5</code> (e.g. lack of a C-Compiler)
|
|
</dd>
|
|
<p></p>
|
|
<dt></dt>
|
|
<dd>
|
|
encrypting only small amounts of data (less than one million bytes). I use it to
|
|
hash passwords.
|
|
</dd>
|
|
<p></p>
|
|
<dt></dt>
|
|
<dd>
|
|
educational purposes
|
|
</dd>
|
|
<p></p></dl>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
|
<pre>
|
|
# Functional style
|
|
use Digest::MD5 qw(md5 md5_hex md5_base64);</pre>
|
|
<pre>
|
|
$hash = md5 $data;
|
|
$hash = md5_hex $data;
|
|
$hash = md5_base64 $data;</pre>
|
|
<pre>
|
|
# OO style
|
|
use Digest::MD5;</pre>
|
|
<pre>
|
|
$ctx = Digest::MD5->new;</pre>
|
|
<pre>
|
|
$ctx->add($data);
|
|
$ctx->addfile(*FILE);</pre>
|
|
<pre>
|
|
$digest = $ctx->digest;
|
|
$digest = $ctx->hexdigest;
|
|
$digest = $ctx->b64digest;</pre>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
<p>This modules has the same interface as the much faster <code>Digest::MD5</code>. So you can
|
|
easily exchange them, e.g.</p>
|
|
<pre>
|
|
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'
|
|
}
|
|
}</pre>
|
|
<p>If the <code>Digest::MD5</code> module is available it is used and if not you take
|
|
<code>Digest::Perl::MD5</code>.</p>
|
|
<p>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.</p>
|
|
<p>For a detailed Documentation see the <code>Digest::MD5</code> module.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="examples">EXAMPLES</a></h1>
|
|
<p>The simplest way to use this library is to import the <code>md5_hex()</code>
|
|
function (or one of its cousins):</p>
|
|
<pre>
|
|
use Digest::Perl::MD5 'md5_hex';
|
|
print 'Digest is ', md5_hex('foobarbaz'), "\n";</pre>
|
|
<p>The above example would print out the message</p>
|
|
<pre>
|
|
Digest is 6df23dc03f9b54cc38a0fc1483df6e21</pre>
|
|
<p>provided that the implementation is working correctly. The same
|
|
checksum can also be calculated in OO style:</p>
|
|
<pre>
|
|
use Digest::MD5;
|
|
|
|
$md5 = Digest::MD5->new;
|
|
$md5->add('foo', 'bar');
|
|
$md5->add('baz');
|
|
$digest = $md5->hexdigest;
|
|
|
|
print "Digest is $digest\n";</pre>
|
|
<p>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:</p>
|
|
<pre>
|
|
$md5->clone->hexdigest</pre>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="limitations">LIMITATIONS</a></h1>
|
|
<p>This implementation of the MD5 algorithm has some limitations:</p>
|
|
<dl>
|
|
<dt></dt>
|
|
<dd>
|
|
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 usefull
|
|
for encrypting small amounts of data like passwords.
|
|
</dd>
|
|
<p></p>
|
|
<dt></dt>
|
|
<dd>
|
|
You can only encrypt up to 2^32 bits = 512 MB on 32bit archs. But You should
|
|
use <code>Digest::MD5</code> for those amounts of data anyway.
|
|
</dd>
|
|
<p></p></dl>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
|
<p><a href="glist.cgi?do=admin_gtdoc&topic=/Digest/MD5.html">the Digest::MD5 manpage</a></p>
|
|
<p><em>md5(1)</em></p>
|
|
<p>RFC 1321</p>
|
|
<p>tools/md5: a small BSD compatible md5 tool written in pure perl.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
|
<p>This library is free software; you can redistribute it and/or
|
|
modify it under the same terms as Perl itself.</p>
|
|
<pre>
|
|
Copyright 2000 Christian Lackas, Imperia Software Solutions
|
|
Copyright 1998-1999 Gisle Aas.
|
|
Copyright 1995-1996 Neil Winton.
|
|
Copyright 1991-1992 RSA Data Security, Inc.</pre>
|
|
<p>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:</p>
|
|
<dl>
|
|
<dt></dt>
|
|
<dd>
|
|
Copyright (C) 1991-1992, RSA Data Security, Inc. Created 1991. All
|
|
rights reserved.
|
|
</dd>
|
|
<dd>
|
|
<p>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.</p>
|
|
</dd>
|
|
<dd>
|
|
<p>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.</p>
|
|
</dd>
|
|
<dd>
|
|
<p>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.</p>
|
|
</dd>
|
|
<dd>
|
|
<p>These notices must be retained in any copies of any part of this
|
|
documentation and/or software.</p>
|
|
</dd>
|
|
<p></p></dl>
|
|
<p>This copyright does not prohibit distribution of any version of Perl
|
|
containing this extension under the terms of the GNU or Artistic
|
|
licenses.</p>
|
|
<p>
|
|
</p>
|
|
<hr />
|
|
<h1><a name="authors">AUTHORS</a></h1>
|
|
<p>The original MD5 interface was written by Neil Winton
|
|
(<N.Winton (at) axion.bt.co.uk>).</p>
|
|
<p><code>Digest::MD5</code> was made by Gisle Aas <gisle (at) aas.no> (I took his Interface
|
|
and part of the documentation).</p>
|
|
<p>Thanks to Guido Flohr for his 'use integer'-hint.</p>
|
|
<p>This release was made by Christian Lackas <delta (at) lackas.net>.</p>
|
|
|
|
</body>
|
|
|
|
</html>
|