def test_encrypt_decrypt_cycle(salt, password, message): encrypted = fernet_encrypt(message, salt, password) assert isinstance(encrypted, str) decrypted = fernet_decrypt(encrypted, salt, password) assert isinstance(decrypted, bytes) assert decrypted == force_bytes(message)
def decrypt(self, key, device, private_key): """Decrypt the specific key on this entry for a specific device. ... note:: This is only used for cloud-stored passwords so the code can reside here in the model. Each client must implement this functionality itself. """ device_key = base64.b64decode(self.keys[device.id.hex]) master_key = private_key_decrypt(private_key, device_key) if master_key is None: return return fernet_decrypt(self.values[key], master_key, self.salt)