Path: utzoo!attcan!uunet!mstan!chuck From: chuck@Morgan.COM (Chuck Ocheret) Newsgroups: comp.emacs Subject: Re: Crypt Message-ID: <1215@s5.Morgan.COM> Date: 10 Jul 90 21:35:26 GMT References: Distribution: comp Organization: Morgan Stanley, & Co., Inc. / New York City, NY Lines: 33 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 +---------------+