Пример #1
0
 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)
Пример #2
0
 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 ...')
Пример #3
0
 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 ...')
Пример #4
0
 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
Пример #5
0
 def aes_encrypt(self, plaintext):
     cryptor = Cryptor()
     cipher = cryptor.aes_encrypt(plaintext, LOCAL_MODE)
     return cipher
Пример #6
0
 def json_tx(self):
     cryptor = Cryptor()
     return json.loads(
         cryptor.aes_decrypt(self.queryset.first().tx, mode=LOCAL_MODE)
     )
Пример #7
0
 def aes_decrypt(self, cipher):
     cryptor = Cryptor()
     plaintext = cryptor.aes_decrypt(cipher, LOCAL_MODE)
     return plaintext
Пример #8
0
def aes_decrypt(cipher_text):
    return Cryptor().aes_decrypt(cipher_text, LOCAL_MODE)
Пример #9
0
 def json_tx(self):
     cryptor = Cryptor()
     return json.loads(cryptor.aes_decrypt(
         self.queryset.first().tx, mode=LOCAL_MODE))
Пример #10
0
 def aes_encrypt(self, plaintext):
     cryptor = Cryptor()
     cipher = cryptor.aes_encrypt(plaintext, LOCAL_MODE)
     return cipher
Пример #11
0
 def aes_decrypt(self, cipher):
     cryptor = Cryptor()
     plaintext = cryptor.aes_decrypt(cipher, LOCAL_MODE)
     return plaintext