From f1504f7162c8c43e3b06dd279370451e9b683e9c Mon Sep 17 00:00:00 2001 From: Brian Sherson Date: Tue, 27 Aug 2013 20:25:22 -0700 Subject: --- wallet.py | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) mode change 100644 => 120000 wallet.py (limited to 'wallet.py') diff --git a/wallet.py b/wallet.py deleted file mode 100644 index 05321f0..0000000 --- a/wallet.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -import pickle, Crypto.Cipher.Blowfish, os, getpass -from threading import Lock - -class Wallet(dict): - def __init__(self, filename): - self.lock=Lock() - if os.path.isfile(filename): - self.f=open(filename,"rb+") - self.passwd=getpass.getpass() - self.crypt=Crypto.Cipher.Blowfish.new(self.passwd) - contents_encrypted=self.f.read() - contents=self.crypt.decrypt(contents_encrypted+"\x00"*((-len(contents_encrypted))%8)) - if contents.startswith(self.passwd): - self.update(dict(pickle.loads(contents[len(self.passwd):]))) - else: - self.f.close() - raise BaseException, "Incorrect Password" - else: - self.f=open(filename,"wb+") - passwd=self.passwd=None - while passwd==None or passwd!=self.passwd: - passwd=getpass.getpass("Enter new password: ") - self.passwd=getpass.getpass("Confirm new password: ") - if passwd!=self.passwd: print "Passwords do not match!" - self.crypt=Crypto.Cipher.Blowfish.new(self.passwd) - self.flush() - def flush(self): - contents=self.passwd+pickle.dumps(self.items(), protocol=2) - self.lock.acquire() - try: - self.f.seek(0) - self.f.write(self.crypt.encrypt(contents+"\x00"*((-len(contents))%8))) - self.f.truncate() - self.f.flush() - finally: - self.lock.release() diff --git a/wallet.py b/wallet.py new file mode 120000 index 0000000..eba4a72 --- /dev/null +++ b/wallet.py @@ -0,0 +1 @@ +../wallet.py \ No newline at end of file -- cgit v1.2.3