[comp.emacs] Crypt

aaron@rruxh.UUCP (Akman) (07/09/90)

One of the few things I've never seen documented (or hidden)
anywhere in GnuEMACS is a feature for editing encrypted files.  Like

	vi -x file

Is there an easy way to do that?
--

-----------
Aaron Akman, 201-699-8019, bellcore!rruxh!aaron, RRC 4D-728

bob@MorningStar.Com (Bob Sutterfield) (07/09/90)

In article <AARON.90Jul9082513@rruxh.rruxh.UUCP> aaron@rruxh.UUCP (Akman) writes:
   One of the few things I've never seen documented (or hidden)
   anywhere in GnuEMACS is a feature for editing encrypted files.

Get tut.cis.ohio-state.edu:pub/gnu/emacs/elisp-archives/misc/crypt.el.Z
(same as osu-cis!~/gnu/emacs/elisp-archives/misc/crypt.el.Z).  It
handles encrypted, compacted, or compressed files with style and
grace.

chuck@Morgan.COM (Chuck Ocheret) (07/11/90)

The following code allows you encrypt and decrypt a buffer that is
already in emacs.  It is a quick hack so it is inefficient.  I would
like to see a better version.  You could write a function that would
invoke this from the command line to vi -x functionality.

----------------------cut here----------------------
;; crypt.el
(defun rconcat (x) (if (null x) nil (concat (car x) (rconcat (cdr x)))))

(defun read-password (prompt)
  "Reads a password ..."
  (let* ((input-char (read-key-sequence prompt))
         (password-list (list input-char)))
    (while (null (equal input-char "\015"))
      (setq input-char (read-key-sequence prompt))
      (cond ((equal input-char "\015") t)
            ((or (equal input-char "\177") (equal input-char "\010"))
             (setq password-list (cdr password-list)))
            (t (setq password-list (cons input-char password-list)))))
    (rconcat (reverse password-list))))

(defun crypt-buffer()
  (interactive)
  (let ((key (read-password "Crypt Key: ")))
    (call-process-region (point-min) (point-max) "crypt" t t nil key)
    (goto-char 1)
    (message "")))
----------------------cut here----------------------
-- 
+--------------------+   Chuck Ocheret, Sr. Staff Engineer   +---------------+
|chuck@APT.Morgan.COM|       Morgan Stanley & Co., Inc.      |(212) 703-4474 |
|    Duty now ...    |19th Floor, 1251 Avenue of the Americas|for the future.|
+--------------------+      New York, N.Y.  10020 USA        +---------------+