示例#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 ...')
 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
 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