=encoding euc-jp =head1 名前 Digest::Perl::MD5 - Ron RivestsのMD5アルゴリズムのPerlによる実装 ※訳注: オリジナルのドキュメントでは、Digest::MD5::Perl となっていますが、誤りなので翻訳で修正しています。 =head1 責任放棄(=DISCLAIMER) これはMD5の(Cのような)インターフェースではB<なく>、Perlによる実装です。 これはperlだけで書かれており、そのため速くはありませんが、Cのコードなしに動きます。 もし利用できるのであれば、このモジュールの代わりにCを使うべきです。 このモジュールは以下のような場合にのみ有効です =over 4 =item (e.g. Cコンパイラがないなど)C をインストールすることができないコンピュータ =item 少量の(百万バイト未満)データだけを暗号化する場合。私はパスーワードをハッシュする のに使っています。 =item 教育的な目的 =back =head1 概要 ※訳注: 以下のコードはオリジナルのドキュメントでは、Digest::Perl::MD5 となっているところは、Digest::MD5 と書かれています誤りなので、翻訳で修正しています。 # 関数形式 use Digest::Perl::MD5 qw(md5 md5_hex md5_base64); $hash = md5 $data; $hash = md5_hex $data; $hash = md5_base64 $data; # OO形式 use Digest::Perl::MD5; $ctx = Digest::Perl::MD5->new; $ctx->add($data); $ctx->addfile(*FILE); $digest = $ctx->digest; $digest = $ctx->hexdigest; $digest = $ctx->b64digest; =head1 説明 このモジュールは、これよりもはるかに速いCと同じインタフェースを 持っています。そのため簡単に入れ替えることができます。例えば。 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' } } もしCモジュールが利用できるのであれば、そちらを使い、 なければ、Cを取ればいいでしょう。 Digest::Perl::MD5とあわせてDigest::MD5のPerl部分をインストールし、 通常通りDigest::MD5を使うことも出来ます。そのオブジェクトファイルを ロードすることができなければDigest::Perl::MD5に戻ります。 さらに詳細なドキュメントについては、Cモジュールを ご覧ください。 =head1 例 このライブラリを利用する最も簡単な方法は、md5_hex()関数 (あるいはその類)をインポートすることです: use Digest::Perl::MD5 'md5_hex'; print 'Digest is ', md5_hex('foobarbaz'), "\n"; その実装が正しく動作するように規定されていれば、上記の例は 以下のメッセージを出力します Digest is 6df23dc03f9b54cc38a0fc1483df6e21 同じチェックサムをOO形式で計算することもできます: use Digest::MD5; $md5 = Digest::MD5->new; $md5->add('foo', 'bar'); $md5->add('baz'); $digest = $md5->hexdigest; print "Digest is $digest\n"; =head1 制約 このMD5アルゴリズムの実装には、いくつかの制約があります: =over 4 =item 遅い、とても遅いです。私は出来うる限りを尽くしました。しかしそれでもDigest::MD5のほうが約135倍 速いのです。容認できる時間内には百万バイトまでのデータしか暗号化することはできません。 しかしパスワードのような少量のデータを暗号化するためには非常に便利です。 =item 32ビットアーキテクチャでは2^32 ビット = 512 MBまでしか暗号化することができません。 そのような量のデータにはCを使うべきです。 =item Cは暗号化するデータを全てメモリにロードします。 これは今後の課題(=todo)になっています。 =back =head1 参考資料 L L RFC 1321 =head1 著作権(=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: =over 4 =item Copyright (C) 1991-2, 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. =back This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses. =head1 作者(=AUTHORS) オリジナルのMD5インターフェースはNeil Winton(C)に よって書かれました。 CはGisle Aas によって作成されました。 (私は彼のインタフェースとドキュメントの一部をとっています) 'use integer'というヒントに対してGuido Flohrに感謝します。 このリリースはChristian Lackas によって作成されました。 =head1 翻訳者 川合孝典 (GCD00051@nifty.ne.jp)