Bitwise Xor Python
I am trying to solve a problem where I have to decrypt a file. But I found an obstacle. As you can see in the below code, I need to do a bitwise xor between key and number 47. fro
Solution 1:
because you need an int
ascii_code_for_a = ord('a') == 97#convert a character to an ascii integerint2chr = chr(97) == 'a'#convert an ascii code back to a character
so just do
key = list(iv) # first convert it to a list ... strings are unmutablefor i inrange(len(key)):
key[i] = chr(ord(key[i]) ^ 47)
Post a Comment for "Bitwise Xor Python"