def test_crypto(self):
        key = binascii.a2b_base64("yyUKYpE1IsMCBdmSAs7FpxWwRszfSbPBqD+Obi3P7Cg28SpLuqB4eA==")
        #s = "vtpGn1C4TbvR/Z7P4qVRij/UGYwcB16D5gTR18cOF+AZhgJqSM/LkVXWAMxFWs5NK83EyZ42/6Y0kkpMJgMGw9IrRBawtsrwI8+5Ty1r+5Wi8KsMXY5hbUmujbwghuVOGpWR4WrTQ/kUARo5oE8U196t97jXVp6r7zSgPe94MyGSHw0+EDZzYXS/q1jePoHaZSSD+meyts9KGzMHAAvvN2E1"
 
        se = cryptotool.encrypt("12345678", key)
        print se
 
        so = cryptotool.decrypt(se, key)
        self.assertEqual(so, "12345678")
 
        print so
Example #2
0
    def test_crypto(self):
        key = binascii.a2b_base64("yyUKYpE1IsMCBdmSAs7FpxWwRszfSbPBqD+Obi3P7Cg28SpLuqB4eA==")
        #s = "vtpGn1C4TbvR/Z7P4qVRij/UGYwcB16D5gTR18cOF+AZhgJqSM/LkVXWAMxFWs5NK83EyZ42/6Y0kkpMJgMGw9IrRBawtsrwI8+5Ty1r+5Wi8KsMXY5hbUmujbwghuVOGpWR4WrTQ/kUARo5oE8U196t97jXVp6r7zSgPe94MyGSHw0+EDZzYXS/q1jePoHaZSSD+meyts9KGzMHAAvvN2E1"

        se = cryptotool.encrypt("12345678", key)
        print se

        so = cryptotool.decrypt(se, key)
        self.assertEqual(so, "12345678")

        print so
Example #3
0
    def in_protocol_filter(self, consumer, queue, message):
        try:
            # Decrypt message
            cnf = bus.cnf
            self._logger.debug('Decrypting message')
            crypto_key = binascii.a2b_base64(cnf.read_key(self.crypto_key_path))
            xml = cryptotool.decrypt(message, crypto_key)

            # Remove special chars
            return xml.strip(''.join(chr(i) for i in range(0, 31)))

        except:
            raise MessagingError('Cannot decrypt message. raw message: %s', message)
Example #4
0
    def in_protocol_filter(self, consumer, queue, message):
        try:
            # Decrypt message
            cnf = bus.cnf
            self._logger.debug('Decrypting message')
            crypto_key = binascii.a2b_base64(cnf.read_key(self.crypto_key_path))
            xml = cryptotool.decrypt(message, crypto_key)

            # Remove special chars
            return xml.strip(''.join(chr(i) for i in range(0, 31)))

        except (BaseException, Exception), e:
            raise MessagingError('Cannot decrypt message. error: %s; raw message: %s' % (e, message))
Example #5
0
    def in_protocol_filter(self, consumer, queue, message):
        try:
            # Decrypt message
            cnf = bus.cnf
            self._logger.debug('Decrypting message')
            crypto_key = binascii.a2b_base64(cnf.read_key(
                self.crypto_key_path))
            xml = cryptotool.decrypt(message, crypto_key)

            # Remove special chars
            return xml.strip(''.join(chr(i) for i in range(0, 31)))

        except:
            self._logger.debug('Decryption error', exc_info=sys.exc_info())
            self._logger.debug('Crypto key: %s', crypto_key)
            self._logger.debug('Raw message: %s', message)
            raise MessagingError('Cannot decrypt message')
Example #6
0
 def decrypt_data(self, data):
     try:
         return cryptotool.decrypt(data, self._read_crypto_key())
     except:
         raise rpc.InvalidRequestError('Failed to decrypt data')
Example #7
0
 def decrypt_data(self, data):
     try:
         return cryptotool.decrypt(data, self._read_crypto_key())
     except:
         raise rpc.InvalidRequestError('Failed to decrypt data')