Update FSF's address in GPL notices.
[elisp/flim.git] / md5.el
1 ;;; md5.el --- MD5 Message Digest Algorithm.
2
3 ;; Copyright (C) 1999, 2001  Free Software Foundation, Inc.
4
5 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
6 ;; Keywords: MD5, RFC 1321
7
8 ;; This file is part of FLIM (Faithful Library about Internet Message).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or
13 ;; (at your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; Test cases from RFC 1321.
28 ;;
29 ;; (md5 "")
30 ;; => d41d8cd98f00b204e9800998ecf8427e
31 ;;
32 ;; (md5 "a")
33 ;; => 0cc175b9c0f1b6a831c399e269772661
34 ;;
35 ;; (md5 "abc")
36 ;; => 900150983cd24fb0d6963f7d28e17f72
37 ;;
38 ;; (md5 "message digest")
39 ;; => f96b697d7cb7938d525a2f31aaf161d0
40 ;;
41 ;; (md5 "abcdefghijklmnopqrstuvwxyz")
42 ;; => c3fcd3d76192e4007dfb496cca67e13b
43 ;;
44 ;; (md5 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
45 ;; => d174ab98d277d9f5a5611c2c9f419d9f
46 ;;
47 ;; (md5 "12345678901234567890123456789012345678901234567890123456789012345678901234567890")
48 ;; => 57edf4a22be3c955ac49da2e2107b67a
49
50 ;;; Code:
51
52 (defvar md5-dl-module
53   (cond
54    ((and (fboundp 'md5)
55          (subrp (symbol-function 'md5)))
56     nil)
57    ((fboundp 'dynamic-link)
58     ;; Should we take care of `dynamic-link-path'?
59     (let ((path (expand-file-name "md5.so" exec-directory)))
60       (if (file-exists-p path)
61           path
62         nil)))
63    (t
64     nil)))
65
66 (cond
67  ((and (fboundp 'md5)
68        (subrp (symbol-function 'md5)))
69   ;; do nothing.
70   )
71  ((and (stringp md5-dl-module)
72        (file-exists-p md5-dl-module))
73   (require 'md5-dl))
74  (t
75   (require 'md5-el)))
76
77 (provide 'md5)
78
79 ;;; md5.el ends here