Exemplo n.º 1
0
    def verify_message(self):
        '''
       Precisamos verificar se o conteudo da formado na messagem esta 
       cozidenente com padrao IEEE 1451
       como por exemp se o tamanho de messagem possuem o memso tamanho do
       corpo da messagem 

       Require Destination TransducerChannel 
       '''
        channel = self.destination()
        command = self.commandClass()
        function = self.commandFunction()
        length = self.length()
        msg = self.commandDependent()

        length = hex2dec(length)

        if not channel > 0:
            raise Exception("Error XdcrOperate Channel is not greater 0")

        if not length == len(msg):
            raise Exception(
                "Error XdcrOperate Message length dependent comand")

        if not command == self.statusCode:
            raise Exception
        functions = ['01', '02', '03']
        if not function in functions:
            raise Exception('Error Status Commands Functions in XdcrOperate')
Exemplo n.º 2
0
    def pipeline(self):

        #Reorganizando o arquivo para formar pares de octetos
        # Por exemplo [00aabbcc] -> [00, aa, bb, cc]
        blockcode = [
            self.blockcode()[i:i + 2]
            for i in range(0, len(self.blockcode()), 2)
        ]

        result = {}

        while len(blockcode) > 0:

            try:
                type = blockcode.pop()
                key, function = self.stages[type]
            except KeyError as error:
                print(f"Error BlockCode TEDS invalid ID: {error}")

            length = hex2dec(blockcode.pop())

            try:
                value = blockcode[:length]
                result.update(function(value))

                #increments
                blockcode = blockcode[length:]
            except (KeyError, IndexError) as error:
                print(
                    f"Error to Construct {self.name} type {key} BlockCode: {error}"
                )

        result['Name'] = self.name

        return result
Exemplo n.º 3
0
    def verify_message(self):
        '''
       Precisamos verificar se o conteudo da formado na messagem esta 
       cozidenente com padrao IEEE 1451
       como por exemp se o tamanho de messagem possuem o memso tamanho do
       corpo da messagem 
       '''
        channel = self.destination()
        command = self.commandClass()
        function = self.commandFunction()
        length = self.length()
        msg = self.commandDependent()

        length = hex2dec(length)

        if not length == len(msg):
            raise Exception("Error Xdcr Message length dependent comand")

        if not command == self.statusCode:
            raise Exception(
                f"Error Xdcr status code Command is not equal $(self.statusCode) "
            )

        if not function in self.codeStates.keys():
            raise Exception('Error Status Commands Functions in XdcrOperate')
Exemplo n.º 4
0
def xor_cipher(string_hex):
    string_dec = hex2dec(string_hex)
    xor_array = [""] * 256
    for i in range(0, 256):
        xor_tmp = ""
        for x in string_dec:
            xor_tmp += chr(ord(x) ^ i)
            xor_array[i] = xor_tmp
    return xor_array
Exemplo n.º 5
0
 def Version(self, code):
     return {"Version": hex2dec(code)}
Exemplo n.º 6
0
 def MaxRDev(self, code):
     return {"MaxRDev": hex2dec(code)}
Exemplo n.º 7
0
 def MaxChan(self, code):
     '''Uint16 1 '''
     return { 
         'MaxChan' : hex2dec(code) 
     }
         
Exemplo n.º 8
0
 def phyFreq(self, code):
     return {"phyFreq": hex2dec(code)}
Exemplo n.º 9
0
 def RangeMax(self, code):
     return {"RangeMax": hex2dec(code)}
Exemplo n.º 10
0
 def ChanType(self, code): 
     return { 
         'ChanType' : hex2dec(code) 
     }
Exemplo n.º 11
0
 def MaxBPS(self, code):
     return {"MaxBPS": hex2dec(code)}
Exemplo n.º 12
0
 def Ecrypt(self, code):
     return {"Ecrypt": hex2dec(code)}
Exemplo n.º 13
0
from binascii import hexlify
from utils import hex2dec, xor_strings
from huepy import run, info, good, bad

if __name__ == '__main__':

    # Write a function that takes two equal-length buffers
    # and produces their XOR combination.

    # If your function works properly, then when you feed it the string:
    string1_hex = "1c0111001f010100061a024b53535009181c"
    print(run(f'string1 hex: {string1_hex}'))
    string1_dec = hex2dec(string1_hex, True)
    print(run(f'string1 decoded: {string1_dec}'))

    # ... after hex decoding, and when XOR'd against:
    string2_hex = "686974207468652062756c6c277320657965"
    print(run(f'string2 hex: {string2_hex}'))
    string2_dec = hex2dec(string2_hex, True)
    print(run(f'string2 decoded: {string2_dec}'))

    # ... should produce:
    expected_result = "746865206b696420646f6e277420706c6179"
    xored_dec = xor_strings(string1_dec, string2_dec, bytes_out=True)
    print(info(f'xored_decoded: {xored_dec}'))
    xored_hex = hexlify(xored_dec).decode('utf-8')
    print(info(f'xored_hex: {xored_hex}'))
    print(info(f'expected_result: {xored_hex}'))
    if xored_hex == expected_result:
        print(good('result true'))
    else:
Exemplo n.º 14
0
 def Baterry(self, code):
     return {"Baterry": hex2dec(code)}
Exemplo n.º 15
0
 def MaxXact(self, code):
     return {"MaxXact": hex2dec(code)}
Exemplo n.º 16
0
 def MinTLat(self, code):
     return {"MinALat": hex2dec(code)}
Exemplo n.º 17
0
 def MaxSDU(self, code):
     return {"MaxSDU": hex2dec(code)}
Exemplo n.º 18
0
 def Authent(self, code):
     ''' Duvida'''
     return {"Authent": hex2dec(code)}
Exemplo n.º 19
0
 def MaxRetry(self, code):
     return {"MaxRetry": hex2dec(code)}
Exemplo n.º 20
0
 def Phy_Ch(self, code):
     return {"Phy_Ch": hex2dec(code)}
Exemplo n.º 21
0
 def CalKey(self, code): 
     return {
         'Calkey': hex2dec(code)  
         }
Exemplo n.º 22
0
 def Phy_ch_w(self, code):
     return {"Phy_ch_w": hex2dec(code)}
Exemplo n.º 23
0
 def SelfTest(self, code): 
     return {
         "SelfTEst" : hex2dec(code)
     }
Exemplo n.º 24
0
 def Radio(self, code):
     return {"Radio": hex2dec(code)}