home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / w3 / md5.el < prev    next >
Encoding:
Text File  |  1995-04-17  |  2.3 KB  |  62 lines

  1. ;;; md5.el,v --- MD5 functionality for emacsen without it builtin
  2. ;; Author: wmperry
  3. ;; Created: 1995/04/14 23:47:48
  4. ;; Version: 1.2
  5. ;; Keywords: mail, news, tools, hypermedia
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7. ;;; Copyright (c) 1993, 1994, 1995 by William M. Perry (wmperry@spry.com)
  8. ;;;
  9. ;;; This file is not part of GNU Emacs, but the same permissions apply.
  10. ;;;
  11. ;;; GNU Emacs is free software; you can redistribute it and/or modify
  12. ;;; it under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 2, or (at your option)
  14. ;;; any later version.
  15. ;;;
  16. ;;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Emacs; see the file COPYING.  If not, write to
  23. ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  25.  
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27. ;;; Copyright (c) 1995 by William M. Perry (wmperry@spry.com)
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29.  
  30. ;; This code is ripped off from vm-pop.el
  31. ;; A short-term
  32.  
  33. (defvar md5-program "md5"
  34.   "*Program that reads a message on its standard input and writes an
  35. MD5 digest on its output.")
  36.  
  37. (defun md5 (object &optional start end)
  38.   (let ((buffer nil))
  39.     (unwind-protect
  40.     (save-excursion
  41.       (setq buffer (generate-new-buffer "*md5-work*"))
  42.       (set-buffer buffer)
  43.       (cond
  44.        ((bufferp object)
  45.         (insert-buffer-substring object start end))
  46.        ((stringp object)
  47.         (insert (if (or start end)
  48.             (substring object start end)
  49.               object)))
  50.        (t nil))
  51.       (call-process-region (point-min) (point-max)
  52.                    (or shell-file-name "/bin/sh")
  53.                    t buffer nil
  54.                    "-c" md5-program)
  55.       ;; MD5 digest is 32 chars long
  56.       ;; mddriver adds a newline to make neaten output for tty
  57.       ;; viewing, make sure we leave it behind.
  58.       (buffer-substring (point-min) (+ (point-min) 32)))
  59.       (and buffer (kill-buffer buffer)))))
  60.  
  61. (provide 'md5)
  62.