def decrypt(encrypted_bytes): if use_m2crypto: secret = Secret() secret.deserialize(encrypted_bytes) return secret.decrypt(encrypted_cookie_key()) else: cipher = pycrypto_cipher() return cipher.decrypt(encrypted_bytes)
def test_unicode(self): secret = Secret() secret.encrypt(u'foo', 'some-key') res = secret.serialize() reverse = Secret() reverse.deserialize(res) assert reverse.decrypt('some-key') == b'foo'
def _decrypt(self, value): secret = Secret() secret.deserialize(value) return smart_text(secret.decrypt(self.get_aes_key()))
def test_legacy_compatibility(self, expected, serialized_secret): secret = Secret() secret.deserialize(serialized_secret) assert secret.decrypt('super-secret-encryption-key') == expected
def decrypt(encrypted_bytes): secret = Secret() secret.deserialize(encrypted_bytes) return secret.decrypt(encrypted_cookie_key())