gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

generic mode for pgp encrypted files e.g. to store passwords


From: Josef Bauer
Subject: generic mode for pgp encrypted files e.g. to store passwords
Date: 31 Jul 2004 22:04:11 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Hi,

I store my passwords and such in a pgp encrypted file
('secrets.pgp'). I found the package package 'mc-auto-encrypt.el' on
http://www.emacswiki.org but was not really content with it. So I took
all my very much limited lisp knowledge to write a generic mode to
handle such a file comfortably within emacs. Now when I open
'secrets.pgp' the content gets decrypted and it is encrypted before it
is written to disk. That's basically it.

I tested the mode with (GNU) emacs 21.3.1, pgp 2.6.3in and
mailcrypt-3.5b7.

I hope that anyone finds this stuff useful or even improves it. Just
keep me informed in case.

Here is the relevant part of my '.emacs':

;----------------------------------------------------------------------
(define-generic-mode 'mc-pgp-file-mode
  (list ?#) 
  nil nil
  '(".pgp\\'" ".pgp-encrypted\\'")
  (list (lambda () 
          (add-hook 'local-write-file-hooks
                    (lambda () 
                      (setq mc-pgp-always-sign 'never)
                      (mc-pgp-encrypt-region 
                       (list mc-pgp-user-id) 
                       (point-min) (point-max) 0)
                      nil
                      ) nil t)
          (add-hook 'after-save-hook 
                    (lambda () (mc-decrypt)
                      (set-buffer-modified-p nil)) 
                    nil t)
          (mc-decrypt)
          (auto-save-mode nil)
          (set-buffer-modified-p nil))
        )
  "Mode for pgp encrypted files"
  )
;----------------------------------------------------------------------

Best regards

Josef


PS : sender address is valid but unread, just in case remove '.nospam'


reply via email to

[Prev in Thread] Current Thread [Next in Thread]