Example #1
0
 def lock(self, pin):
     if self.cipherpassword is None:
         if self.iv is None:
             self.iv = utilities.generate_iv()
         key = utilities.generate_key(self.domain, self.username, pin)
         self.cipherpassword = utilities.encrypt(key, self.iv, self.plainpassword)
     return self.cipherpassword, self.iv
Example #2
0
 def create(path, database_path, **kwargs):
     k = Keyfile()
     k.path = path
     k.database_path = os.path.abspath(database_path)
     k.key = kwargs.get('key', utilities.generate_key())
     k.iv = kwargs.get('iv', utilities.generate_iv())
     k.length = kwargs.get('length', Keyfile.LENGTH)
     k.characters = kwargs.get('characters', Keyfile.CHARACTERS)
     k.save()
     return Keyfile.load(path)
Example #3
0
 def unlock(self, pin):
     if self.plainpassword is None:
         key = utilities.generate_key(self.domain, self.username, pin)
         self.plainpassword = utilities.decrypt(key, self.iv, self.cipherpassword)
     return self.plainpassword