Search code examples
emacsorg-modegnupg

Using GPG with org-mode


What I want is to be able to make a 'heading' under which I can have encrypted data. I should be able to have multiple headings within the same file in emacs.

I had this working, but unfortunately I don't remember what I needed to do in order to encrypt the data. For reference, this is what I had to add to my .emacs to get it working:

(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
;; GPG key to use for encryption
;; Either the Key ID or set to nil to use symmetric encryption.
(setq org-crypt-key nil)

What I've tried so far: using :crypt: before my heading, running M-x org-encrypt-entry on the heading.


Solution

  • Your config of org-crypt is enough to get it working. I have the same one and all headings with tag :crypt: are encrypted before saving file (with different passfrases). Also, running M-x org-encrypt-entry manually encrypts current heading. Answer to your question can't be found with this description, it needed more details. For example: what happens if you running M-x org-encrypt-entry on heading? Org-crypt should ask passfrase and then replace text within heading. Or headings with tag :crypt: should be encrypted automatically before saving file.

    EDIT: If current heading is syntactically correct (has blue highlight) and command M-x org-encrypt-entry produces error "Before first headline at position ... in buffer ..." then you can check value of variable outline-regexp (command C-h v outline-regexp). It may have incorrect value.

    For me it is "\\*+ " in org-mode buffers.