Created
October 20, 2016 11:45
-
-
Save deadcyclo/f2b435fc84690d528db5371597d40aad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; USE EASY PG IN EMACS TO ENCRYPT CONFIGFILES AND OTHER FILES | |
;; Brendan Johan Lee <[email protected]> | |
;; | |
;; You need Easy PG <http://epg.sourceforge.jp/> Which is included in Emacs >= 23 | |
;; | |
;; | |
;; To activate Easy PG, put the following two lines in your .emacs | |
;; | |
(require 'epa-file) | |
(epa-file-enable) | |
;; | |
;; When you now visit a file with the extension .gpg, you will be prompted for a | |
;; key and emacs will encrypt the file. You will also be prompted when opening | |
;; the file and the file will be decrypted. | |
;; | |
;; If you want to avoid being prompted every time the file is saved, add the | |
;; following to the top of the file in question | |
;; | |
-*- epa-file-encrypt-to: ("[email protected]") -*- | |
;; | |
;; If you prefer symetric encryption, use | |
;; | |
-*- epa-file-encrypt-to: nil -*- | |
;; | |
;; Since these files can be required, you can use this to encrypt sensitive | |
;; configurations (such as service passwords, etc). You will be prompted for | |
;; the password once when the configuration is loaded. The decrypted config will | |
;; be retained in memory as long as the given Emacs instance is running | |
;; | |
;; So if you have a file ~/secret-config.gpg that you would like loaded when | |
;; emacs starts, add | |
;; | |
(require 'secrets "~/secret-config.gpg") | |
;; | |
;; to your .emacs and include the following in ~/secret-config.gpg | |
;; | |
(provide 'secrets) | |
... more lisp code goes here | |
;; | |
;; You will now be prompted for your keyphrase to decrypt the file each time you | |
;; start a new instance of Emacs. | |
;; | |
;; But wait, there is more. You can also do this on demmand instead. Imagine that | |
;; ~/secret-config.pgp contains your usernames and passwords for email in | |
;; Wanderlust, and you only want to load the config when you actually start | |
;; Wanderlust in emacs. You can easily do this by simply hooking require thusly | |
;; | |
(defun mc-wl-load-settings () | |
"Load mail settings from encrypted file + signature support" | |
(require 'wlsecrets "~/secret-config.gpg")) | |
;; | |
;; You can also hook the require as many times as needed, and only be prompted for | |
;; the password for the first time. So if you have some sort of ldap settings you | |
;; could also do | |
;; | |
(defun mc-ldap-search () | |
"Load mail settings from encrypted file and search ldap" | |
(interactive) | |
(require 'wlsecrets "~/secret-config.gpg") | |
(eudc-query-form) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment