Created
July 15, 2016 19:57
-
-
Save asauber/b86e538dc2886d2c7a03c4b97c30048d to your computer and use it in GitHub Desktop.
Decrypt a jrnl journal
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
#!/usr/bin/env python3 | |
from Crypto.Cipher import AES | |
import hashlib | |
import sys | |
import argparse | |
import getpass | |
parser = argparse.ArgumentParser() | |
parser.add_argument("filepath", help="journal file to decrypt") | |
args = parser.parse_args() | |
pwd = getpass.getpass() | |
key = hashlib.sha256(pwd.encode('utf-8')).digest() | |
with open(args.filepath, 'rb') as f: | |
ciphertext = f.read() | |
crypto = AES.new(key, AES.MODE_CBC, ciphertext[:16]) | |
plain = crypto.decrypt(ciphertext[16:]) | |
plain = plain.strip(plain[-1:]) | |
plain = plain.decode("utf-8") | |
print(plain) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment