Encryption reads and writes in binary mode

This commit is contained in:
Manuel Ebert 2015-04-05 06:14:18 +04:00
parent 76c9006ed3
commit 4a7a8cb7a4
2 changed files with 3 additions and 3 deletions

View file

@ -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:]

View file

@ -99,7 +99,7 @@ def prompt(msg):
def py23_input(msg=""):
STDERR.write(u(msg))
prompt(msg)
return STDIN.readline().strip()