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)
예제 #2
0
    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'
예제 #3
0
 def _decrypt(self, value):
     secret = Secret()
     secret.deserialize(value)
     return smart_text(secret.decrypt(self.get_aes_key()))
예제 #4
0
 def test_legacy_compatibility(self, expected, serialized_secret):
     secret = Secret()
     secret.deserialize(serialized_secret)
     assert secret.decrypt('super-secret-encryption-key') == expected
예제 #5
0
 def _decrypt(self, value):
     secret = Secret()
     secret.deserialize(value)
     return smart_text(secret.decrypt(self.get_aes_key()))
def decrypt(encrypted_bytes):
    secret = Secret()
    secret.deserialize(encrypted_bytes)
    return secret.decrypt(encrypted_cookie_key())