2001-12-18 01:00:00 ShengHuo ZHU <zsh@cs.rochester.edu>
[gnus] / lisp / canlock.el
index 89673be..f24a88e 100644 (file)
@@ -45,8 +45,6 @@
   (require 'cl))
 
 (autoload 'sha1-binary "sha1-el")
-(autoload 'sha1-encode-binary "sha1")
-(autoload 'base64-encode "base64")
 
 (defgroup canlock nil
   "The Cancel-Lock feature."
 
 (defcustom canlock-sha1-function 'sha1-binary
   "Function to call to make a SHA-1 message digest."
-  :type '(radio (function-item sha1-encode-binary)
-               (function-item sha1-binary)
+  :type '(radio (function-item sha1-binary)
                (function-item canlock-sha1-with-openssl)
                (function :tag "Other"))
   :group 'canlock)
 
 (defcustom canlock-sha1-function-for-verify canlock-sha1-function
   "Function to call to make a SHA-1 message digest for verifying."
-  :type '(radio (function-item sha1-encode-binary)
-               (function-item sha1-binary)
+  :type '(radio (function-item sha1-binary)
                (function-item canlock-sha1-with-openssl)
                (function :tag "Other"))
   :group 'canlock)
@@ -101,18 +97,23 @@ buffer does not look like a news message."
 
 (defun canlock-sha1-with-openssl (message)
   "Make a SHA-1 digest of MESSAGE using OpenSSL."
-  (with-temp-buffer
-    (let ((coding-system-for-read 'binary)
-         (coding-system-for-write 'binary)
-         selective-display
-         (case-fold-search t))
-      (insert message)
-      (apply 'call-process-region (point-min) (point-max)
-            canlock-openssl-program t t nil canlock-openssl-args)
-      (goto-char (point-min))
-      (while (re-search-forward "[0-9a-f][0-9a-f]" nil t)
-       (replace-match (read (concat "\"\\x" (match-string 0) "\""))))
-      (buffer-substring (point-min) (point)))))
+  (let (default-enable-multibyte-characters)
+    (with-temp-buffer
+      (let ((coding-system-for-read 'binary)
+           (coding-system-for-write 'binary)
+           selective-display
+           (case-fold-search t)
+           (str ""))
+       (insert message)
+       (apply 'call-process-region (point-min) (point-max)
+              canlock-openssl-program t t nil canlock-openssl-args)
+       (goto-char (point-min))
+       (insert "\"")
+       (while (re-search-forward "[0-9a-f][0-9a-f]" nil t)
+         (replace-match (concat "\\\\x" (match-string 0))))
+       (insert "\"")
+       (goto-char (point-min))
+       (read (current-buffer))))))
 
 (defvar canlock-read-passwd nil)
 (defun canlock-read-passwd (prompt &rest args)