Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encrypt individual headings in org-mode?

I have searched everywhere for information on how to use org-crypt to password protect specific headings in org-mode. Most of the info out there says use org-crypt. I have added the org-crypt lines to my .emacs without any luck getting it to work. I think you also have to use gpg but am still unsure.

I have added:

(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt"))) 
;;  set to nil to use symmetric encryption.
(setq org-crypt-key nil)

When I save the file with the crypt tag nothing happens. I think I am missing some kind of connecting code. Anyone know what I am doing wrong? Many Thanks in advance.

like image 458
justinp Avatar asked Oct 26 '25 05:10

justinp


1 Answers

Much internet searching and trial (lots of error) led me to the config below. Essentially you use org-crypt WITH gnupg. Keep in mind I am running macOS Sierra and Emacs 25.2 .

Use homebrew to install gnupg: brew install gnupg2

Add the following lines to your .emacs. It will allow you to encrypt individual headings in an org-file with a passphrase using the TAG :crypt: when added to the heading and saved (C-x C-s). Upon save there will be a pop-up asking for the passphrase.

(require 'epa-file)
(custom-set-variables '(epg-gpg-program  "/usr/local/bin/gpg2"))
(epa-file-enable)

(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt"))) 
;;  set to nil to use symmetric encryption.
(setq org-crypt-key nil)

For good measure:

;; Global Tags
(setq org-tag-alist '(("crypt" . ?c))) 

That should be it. Hope this helps.

like image 99
justinp Avatar answered Oct 28 '25 22:10

justinp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!