I am very new to programming and cryptography, but I took part in a CTF competition where the provided us with a hex and we are supposed to crack it. Through some work and research, I got this code
import binascii
my_ciphertext = "0f05080e1220360106190c3610061c360207061e361e01081d4e1a2e0600070e362607210c1b0c4814"
binary_rep_of_ciphertext = binascii.unhexlify(my_ciphertext)# makes it binary
array_of_ciphertext = bytearray(binary_rep_of_ciphertext)#makes binary things to array elements
def xor_string_and_char(my_char_value):
result= ''.join([chr(cc ^ my_char_value) for cc in array_of_ciphertext])
return '{:x}'.format(result) # convert back to hexadecimal
x = 0
assert x==0
while x in range(255):
my_plaintext = xor_string_and_char(x)
print('b' + my_plaintext)
x=x+1
but I keep getting an error, and I dont know how to fix it. I am not sure what is wrong with the code cause I am not good at python at all (ps: please use newbie language to explain) error: Unknown format code 'x' for object of type 'str'