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 program is free software; you can redistribute it and/or
9 ;; modify it under the terms of the GNU General Public License as
10 ;; published by the Free Software Foundation; either version 2, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
27 (defvar sha1-dl-module
28 (if (and (fboundp 'sha1-string)
29 (subrp (symbol-function 'sha1-string)))
31 (if (fboundp 'dynamic-link)
32 (let ((path (expand-file-name "sha1.so" exec-directory)))
33 (and (file-exists-p path)
36 (defvar sha1-dl-handle
37 (and (stringp sha1-dl-module)
38 (file-exists-p sha1-dl-module)
39 (dynamic-link sha1-dl-module)))
41 ;;; sha1-dl-module provides `sha1-string'.
42 (dynamic-call "emacs_sha1_init" sha1-dl-handle)
44 (defun sha1-region (beg end)
46 (sha1-string (buffer-substring-no-properties beg end)))
49 (defun sha1 (object &optional beg end)
50 "Return the SHA1 (Secure Hash Algorithm) of an object.
51 OBJECT is either a string or a buffer.
52 Optional arguments BEG and END denote buffer positions for computing the
53 hash of a portion of OBJECT."
58 (sha1-region (or beg (point-min)) (or end (point-max))))))
63 ;;; sha1-dl.el ends here.