I have a collection of values as strings and a collection of potential keys. I am trying to make 256 potential ascii strings given all potential one character strings.
my_text = '253224233b32242479'
print(my_text)
for key in string.printable: #all one character ascii charecter
key = key.encode("hex")
key = int(key, 16)
key = key + 0x200
key = hex(key)
total_string = ""
for x in range(0, len(my_text)/2): #scroll through all pairs of hex numbers
original_letter = my_text[x*2:x*2+2]
original_letter = int(original_letter, 16)
original_letter = original_letter + 0x200
original_letter_as_hex = hex(original_letter)
xor_letter = original_letter_as_hex ^ key
total_string = total_string.append(str(xor_letter))
print(total_string)
print(total_string.decode("hex"))
My issue is that the xor_letter = original_letter_as_hex ^ key
gives: TypeError: unsupported operand type(s) for ^: 'str' and 'str'
So, how can I convert for instance '25' to something that can be 'XOR'ed as a hex?
This question is a more in depth question that I asked here: How to convert a hex number that is a string type to a hex type
In short:
>>> key = '0'
>>> key = key.encode('hex')
>>> key = int(key, 16)
>>> key = key + 0x200
>>> key = hex(key)
>>> letter = '0e'
>>> letter = int(letter, 16)
>>> letter = letter + 0x200
>>> letter = hex(letter)
>>> done = key^letter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for ^: 'str' and 'str'
How do i do this? done
should be '3e' which should convert to '>' in ascii.
One hex input '0e'
XORed by one ascii input '0'
is one ascii output '>'
I want a function that can take 2 inputs of as tpye strings and treat one as hex and one as ascii and XOR them like this site: http://xor.pw/?