class PwDb : def __init__(self,path=None,force_create = False): self.pwdb = PlainFileStore(path, force_create) def _get_pwd(self,h, master_password) : if master_password == None : pawd = getpass.getpass("password :"******""" encrypt pwd with the provided master_password """ h = hashlib.sha1(str(time.time())).digest() derived_password = self._get_pwd(h, master_password) ciph = AES.new(derived_password,mode=AES.MODE_CBC,IV=chr(0)*16) plain = crypto_pad(pwd,16) cryptd = ciph.encrypt(plain) return base64.b64encode(cryptd), base64.b64encode(h) def decrypt(self,crypt, h, master_password=None): dp = self._get_pwd(base64.b64decode(h), master_password) ciph = AES.new(dp,mode=AES.MODE_CBC,IV=chr(0)*16) plain = ciph.decrypt(base64.b64decode(crypt)) plain = crypto_unpad(plain,16) return plain
def __init__(self,path=None,force_create = False): self.pwdb = PlainFileStore(path, force_create)