1234567891011121314151617181920212223242526272829 |
- def hash_key_salt(self):
- # --- convert key to hash
- # create a new hash object
- hasher = hashlib.new(self.hash_type)
- hasher.update(self.user_key)
- # turn the output key hash into 32 bytes (256 bits)
- self.hashed_key_salt["key"] = bytes(hasher.hexdigest()[:32], "utf-8")
- # clean up hash object
- del hasher
- # --- convert salt to hash
- # create a new hash object
- hasher = hashlib.new(self.hash_type)
- hasher.update(self.user_salt)
- # turn the output salt hash into 16 bytes (128 bits)
- self.hashed_key_salt["salt"] = bytes(hasher.hexdigest()[:16], "utf-8")
- # clean up hash object
- del hasher
|