1 ;;; md5-dl.el --- MD5 Message Digest Algorithm using DL module.
3 ;; Copyright (C) 1999 Shuhei KOBAYASHI
5 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
6 ;; Keywords: MD5, RFC 1321
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.
30 (if (and (fboundp 'md5-string)
31 (subrp (symbol-function 'md5-string)))
33 (if (fboundp 'dynamic-link)
34 (let ((path (expand-file-name "md5.so" exec-directory)))
35 (and (file-exists-p path)
39 (and (stringp md5-dl-module)
40 (file-exists-p md5-dl-module)
41 (dynamic-link md5-dl-module)))
43 ;;; md5-dl-module provides `md5-string'.
44 (dynamic-call "emacs_md5_init" md5-dl-handle)
46 (defun md5-region (beg end)
48 (md5-string (buffer-substring-no-properties beg end)))
50 ;;; Note that XEmacs built-in version takes two more args: CODING and NOERROR.
52 (defun md5 (object &optional beg end)
53 "Return the MD5 (a secure message digest algorithm) of an object.
54 OBJECT is either a string or a buffer.
55 Optional arguments BEG and END denote buffer positions for computing the
56 hash of a portion of OBJECT."
61 (md5-region (or beg (point-min)) (or end (point-max))))))
66 ;;; md5-dl.el ends here.