CVS update by aidan packages/xemacs-packages/os-utils ...
xemacs-cvs at xemacs.org
xemacs-cvs at xemacs.org
Tue Oct 2 05:32:36 EDT 2007
User: aidan
Date: 07/10/02 11:32:36
Modified: packages/xemacs-packages/os-utils ChangeLog crypt.el
Log:
xemacs-packages/os-utils/crypt.el improvements, from Jaari Aalto.
Revision Changes Path
1.59 +11 -0 XEmacs/packages/xemacs-packages/os-utils/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/os-utils/ChangeLog,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -p -r1.58 -r1.59
--- ChangeLog 2006/09/04 07:52:40 1.58
+++ ChangeLog 2007/10/02 09:32:34 1.59
@@ -1,3 +1,14 @@
+2007-09-29 Jari Aalto <jari.aalto AT cante.net>
+
+ * crypt.el
+ (crypt-encryption-type-get): New function.
+ (crypt-encryption-type-set): New function.
+ (crypt-decrypt-buffer): New interactive function.
+ (crypt-encrypted-p): Call `crypt-encryption-type-set' to set
+ correct `crypt-encryption-type'.
+ (crypt-build-encryption-alist): Add entry for
+ bcrypt program: *.bfe files.
+
2006-09-04 Norbert Koch <viteno at xemacs.org>
* Makefile (VERSION): XEmacs package 1.39 released.
1.8 +44 -3 XEmacs/packages/xemacs-packages/os-utils/crypt.el
Index: crypt.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/os-utils/crypt.el,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- crypt.el 2006/09/04 06:16:11 1.7
+++ crypt.el 2007/10/02 09:32:34 1.8
@@ -919,7 +919,19 @@ absence of `crypt-encryption-magic-regex
t
nil
)
- ;; Add new elements here ...
+ (list 'bfe
+ ;; See http://sourceforge.net/projects/bcrypt
+ crypt-encryption-magic-regexp crypt-encryption-magic-regexp-inverse
+ (or crypt-encryption-file-extension "\\(\\.bfe\\)$")
+ "bcrypt" "bcrypt"
+ '("")
+ '("")
+ "BFE"
+ nil
+ t
+ nil
+ )
+ ;; Add new elements here ...
))
(defconst crypt-encryption-alist (crypt-build-encryption-alist)
@@ -1552,6 +1564,24 @@ Derived from variable `crypt-encoding-al
(setq alist (cdr alist))))
found))))
+(defun crypt-encryption-type-get (file)
+ "Determine type of encryption from file extension."
+ (let (ret
+ regexp)
+ (dolist (elt crypt-encryption-alist)
+ (setq regexp (nth 3 elt))
+ (if (and (stringp regexp)
+ (string-match regexp file))
+ (return (nth 0 elt))))))
+
+(defun crypt-encryption-type-set ()
+ "Set `crypt-encryption-type'"
+ (let (type)
+ (if (setq type (crypt-encryption-type-get buffer-file-name))
+ (progn
+ (setq crypt-encryption-type type)
+ (crypt-rebuild-tables)))))
+
(defun crypt-encrypted-p (&optional buffer)
;; Returns t if current buffer, or optionally BUFFER, is encrypted.
;; Look for MAGIC-REGEXP and absence of MAGIC-REGEXP-INVERSE. If so, then
@@ -1567,7 +1597,7 @@ Derived from variable `crypt-encoding-al
(save-restriction
(widen)
(goto-char (point-min))
-
+ (crypt-encryption-type-set)
(let ((magic-regexp (crypt-get-magic-regexp crypt-encryption-type))
(magic-regexp-inverse (crypt-get-magic-regexp-inverse
crypt-encryption-type))
@@ -2127,6 +2157,17 @@ decryption is done."
(save-excursion (set-buffer buffer)
(crypt-encrypt-region (point-min) (point-max) key decrypt)))
+(defun crypt-decrypt-buffer (key)
+ "Use KEY to decrypt current buffer."
+ (interactive
+ (let (pass)
+ (barf-if-buffer-read-only)
+ (list
+ (crypt-read-string-no-echo
+ "Decrypt buffer using key: "))))
+ (setq crypt-buffer-encryption-key key)
+ (crypt-encrypt-region (point-min) (point-max) key 'decrypt))
+
;;;; ENCODING
@@ -2748,7 +2789,7 @@ see variable `crypt-auto-decode-insert'.
;; Similar to `insert-file-contents' except decoding/decrypting of FILE
;; attempted. See `crypt-insert-file' and `crypt-auto-decode-insert'
-;;
+;;
(defun crypt-insert-file-contents (file)
(let (temp-buffer
temp-list
More information about the XEmacs-CVS
mailing list