From 196531aafc6f2c0652e31669f9d0e1d6ca310c6c Mon Sep 17 00:00:00 2001 From: Stephan Gabler Date: Fri, 13 Apr 2012 20:38:36 +0200 Subject: [PATCH] Checks if password is wrong --- jrnl.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jrnl.py b/jrnl.py index 01d958e8..362fa230 100755 --- a/jrnl.py +++ b/jrnl.py @@ -103,10 +103,12 @@ class Journal: key = self._block_tail(key) self.crypto = AES.new(key, AES.MODE_ECB) journal_plain = self.crypto.decrypt(journal_encrypted) - - print len(journal_plain) - print journal_plain[-16:] - print 'xxxxxxxxxx' + # encrypted files should end with spaces. No spaces, no luck. + while journal_plain[-1] != " ": + key = getpass.getpass('Wrong password. Try again: ') + key = self._block_tail(key) + self.crypto = AES.new(key, AES.MODE_ECB) + journal_plain = self.crypto.decrypt(journal_encrypted) else: journal_plain = f.read()