def __init__(self, *args, **kwargs): self._worklist = {} self.aes_decrypt = Cryptor( aes_encryption_mode=AES_CIPHER.MODE_CFB).aes_decrypt self.aes_encrypt = Cryptor( aes_encryption_mode=AES_CIPHER.MODE_CBC).aes_encrypt super(Command, self).__init__(*args, **kwargs)
def test_outgoingtransaction_serializer_tx_decrypts(self): obj = OutgoingTransaction.objects.last() serializer = OutgoingTransactionSerializer(obj) serializer.data content = JSONRenderer().render(serializer.data) stream = BytesIO(content) data = JSONParser().parse(stream) serializer = OutgoingTransactionSerializer(data=data) serializer.is_valid() cryptor = Cryptor() self.assertTrue(cryptor.aes_decrypt( serializer.validated_data['tx'], LOCAL_MODE)) value = cryptor.aes_decrypt( serializer.validated_data['tx'], LOCAL_MODE).encode() stream = BytesIO(value) json_data = JSONParser().parse(stream) self.assertTrue(json_data[0]['fields']['f1'], 'give any one species too much rope ...')
def encrypted_json(self): """Returns an encrypted json serialized from self. """ json = serialize(objects=[self.instance]) encrypted_json = Cryptor().aes_encrypt(json, LOCAL_MODE) return encrypted_json
def aes_encrypt(self, plaintext): cryptor = Cryptor() cipher = cryptor.aes_encrypt(plaintext, LOCAL_MODE) return cipher
def json_tx(self): cryptor = Cryptor() return json.loads( cryptor.aes_decrypt(self.queryset.first().tx, mode=LOCAL_MODE) )
def aes_decrypt(self, cipher): cryptor = Cryptor() plaintext = cryptor.aes_decrypt(cipher, LOCAL_MODE) return plaintext
def aes_decrypt(cipher_text): return Cryptor().aes_decrypt(cipher_text, LOCAL_MODE)
def json_tx(self): cryptor = Cryptor() return json.loads(cryptor.aes_decrypt( self.queryset.first().tx, mode=LOCAL_MODE))