1 ;;; sha1-dl.el --- SHA1 Secure Hash Algorithm using DL module.
3 ;; Copyright (C) 1999 Shuhei KOBAYASHI
5 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
6 ;; Keywords: SHA1, FIPS 180-1
8 ;; This file is part of FLIM (Faithful Library about Internet Message).
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.
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.
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., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (provide 'sha1-dl) ; beware of circular dependency.
31 (require 'sha1) ; sha1-dl-module.
32 (defun-maybe dynamic-link (a))
33 (defun-maybe dynamic-call (a b)))
35 (defvar sha1-dl-handle
36 (and (stringp sha1-dl-module)
37 (file-exists-p sha1-dl-module)
38 (dynamic-link sha1-dl-module)))
40 ;;; sha1-dl-module provides `sha1-string' and `sha1-binary'.
41 (dynamic-call "emacs_sha1_init" sha1-dl-handle)
43 (defun sha1-region (beg end)
44 (sha1-string (buffer-substring-no-properties beg end)))
46 (defun sha1 (object &optional beg end)
47 "Return the SHA1 (Secure Hash Algorithm) of an object.
48 OBJECT is either a string or a buffer.
49 Optional arguments BEG and END denote buffer positions for computing the
50 hash of a portion of OBJECT."
55 (sha1-region (or beg (point-min)) (or end (point-max))))))
59 ;;; sha1-dl.el ends here