From 4a7a8cb7a481e915ec87c24daf73b6503d677abc Mon Sep 17 00:00:00 2001 From: Manuel Ebert Date: Sun, 5 Apr 2015 06:14:18 +0400 Subject: [PATCH] Encryption reads and writes in binary mode --- jrnl/EncryptedJournal.py | 4 ++-- jrnl/util.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jrnl/EncryptedJournal.py b/jrnl/EncryptedJournal.py index 3fbffa69..17cb880d 100644 --- a/jrnl/EncryptedJournal.py +++ b/jrnl/EncryptedJournal.py @@ -51,7 +51,7 @@ class EncryptedJournal(Journal.Journal): def _store(self, filename, text): key = make_key(self.config['password']) journal = Fernet(key).encrypt(text.encode('utf-8')) - with open(filename, 'w') as f: + with open(filename, 'wb') as f: f.write(journal) @classmethod @@ -70,7 +70,7 @@ class LegacyEncryptedJournal(Journal.LegacyJournal): self.config['encrypt'] = True def _load(self, filename, password=None): - with open(filename) as f: + with open(filename, 'rb') as f: journal_encrypted = f.read() iv, cipher = journal_encrypted[:16], journal_encrypted[16:] diff --git a/jrnl/util.py b/jrnl/util.py index 6d5ba528..8aeb1781 100644 --- a/jrnl/util.py +++ b/jrnl/util.py @@ -99,7 +99,7 @@ def prompt(msg): def py23_input(msg=""): - STDERR.write(u(msg)) + prompt(msg) return STDIN.readline().strip()