Encryption

Encrypting and decrypting

If you don’t choose to encrypt your file when you run jrnl for the first time, you can encrypt your existing journal file or change its password using

jrnl --encrypt

If it is already encrypted, you will first be asked for the current password. You can then enter a new password and your plain journal will replaced by the encrypted file. Conversely,

jrnl --decrypt

will replace your encrypted journal file by a Journal in plain text. You can also specify a filename, ie. jrnl --decrypt plain_text_copy.txt, to leave your original file untouched.

Storing passwords in your keychain

Whenever you encrypt your journal, you are asked whether you want to store the encryption password in your keychain. If you do this, you won’t have to enter your password every time you want to write or read your journal.

If you don’t initially store the password in the keychain but decide to do so at a later point – or maybe want to store it on one computer but not on another – you can simply run jrnl --encrypt on an encrypted journal and use the same password again.

Manual decryption

Should you ever want to decrypt your journal manually, you can do so with any program that supports the AES algorithm. The key used for encryption is the SHA-256-hash of your password, and the IV (initialisation vector) is stored in the first 16 bytes of the encrypted file. So, to decrypt a journal file in python, run:

import hashlib, Crypto.Cipher
key = hashlib.sha256(my_password).digest()
with open("my_journal.txt") as f:
    cipher = f.read()
    crypto = AES.new(key, AES.MODE_CBC, iv = cipher[:16])
    plain = crypto.decrypt(cipher[16:])