;;; sha1.el --- SHA1 Secure Hash Algorithm.
-;; Copyright (C) 1999 Shuhei KOBAYASHI
+;; Copyright (C) 1999, 2001 Free Software Foundation, Inc.
;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
;; Keywords: SHA1, FIPS 180-1
+;; This file is part of FLIM (Faithful Library about Internet Message).
+
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;;; Code:
+(defvar sha1-dl-module
+ (cond
+ ((and (fboundp 'sha1)
+ (subrp (symbol-function 'sha1)))
+ nil)
+ ((fboundp 'dynamic-link)
+ ;; Should we take care of `dynamic-link-path'?
+ (let ((path (expand-file-name "sha1.so" exec-directory)))
+ (if (file-exists-p path)
+ path
+ nil)))
+ (t
+ nil)))
+
(cond
- ((and (fboundp 'dynamic-link)
- (file-exists-p (expand-file-name "sha1.so" exec-directory)))
- ;; Emacs with DL patch.
- (require 'sha1 "sha1-dl"))
+ ((and (stringp sha1-dl-module)
+ (file-exists-p sha1-dl-module))
+ (require 'sha1-dl))
(t
- (require 'sha1 "sha1-el")
- (defun sha1 (object &optional beg end)
- "Return the SHA1 (Secure Hash Algorithm) of an object.
-OBJECT is either a string or a buffer.
-Optional arguments BEG and END denote buffer positions for computing the
-hash of a portion of OBJECT."
- (if (stringp object)
- (sha1-encode object)
- (save-excursion
- (set-buffer object)
- (sha1-encode
- (buffer-substring-no-properties
- (or beg (point-min)) (or end (point-max)))))))
- ))
-
-;;; sha1.el ends here.
+ (require 'sha1-el)))
+
+(provide 'sha1)
+
+;;; sha1.el ends here