update.
[elisp/flim.git] / sha1.el
1 ;;; sha1.el --- SHA1 Secure Hash Algorithm.
2
3 ;; Copyright (C) 1999, 2001  Free Software Foundation, Inc.
4
5 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
6 ;; Keywords: SHA1, FIPS 180-1
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 ;; Examples from FIPS PUB 180-1.
28 ;; <URL:http://www.itl.nist.gov/div897/pubs/fip180-1.htm>
29 ;;
30 ;; (sha1 "abc")
31 ;; => a9993e364706816aba3e25717850c26c9cd0d89d
32 ;;
33 ;; (sha1 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
34 ;; => 84983e441c3bd26ebaae4aa1f95129e5e54670f1
35 ;;
36 ;; (sha1 (make-string 1000000 ?a))
37 ;; => 34aa973cd4c4daa4f61eeb2bdbad27316534016f
38
39 ;;; Code:
40
41 (defvar sha1-dl-module
42   (cond
43    ((and (fboundp 'sha1)
44          (subrp (symbol-function 'sha1)))
45     nil)
46    ((fboundp 'dynamic-link)
47     ;; Should we take care of `dynamic-link-path'?
48     (let ((path (expand-file-name "sha1.so" exec-directory)))
49       (if (file-exists-p path)
50           path
51         nil)))
52    (t
53     nil)))
54
55 (cond
56  ((and (stringp sha1-dl-module)
57        (file-exists-p sha1-dl-module))
58   (require 'sha1-dl))
59  (t
60   (require 'sha1-el)))
61
62 (provide 'sha1)
63
64 ;;; sha1.el ends here