Checks if password is wrong

This commit is contained in:
Stephan Gabler 2012-04-13 20:38:36 +02:00
parent acb7fa2ed4
commit 196531aafc

10
jrnl.py
View file

@ -103,10 +103,12 @@ class Journal:
key = self._block_tail(key) key = self._block_tail(key)
self.crypto = AES.new(key, AES.MODE_ECB) self.crypto = AES.new(key, AES.MODE_ECB)
journal_plain = self.crypto.decrypt(journal_encrypted) journal_plain = self.crypto.decrypt(journal_encrypted)
# encrypted files should end with spaces. No spaces, no luck.
print len(journal_plain) while journal_plain[-1] != " ":
print journal_plain[-16:] key = getpass.getpass('Wrong password. Try again: ')
print 'xxxxxxxxxx' key = self._block_tail(key)
self.crypto = AES.new(key, AES.MODE_ECB)
journal_plain = self.crypto.decrypt(journal_encrypted)
else: else:
journal_plain = f.read() journal_plain = f.read()