I am trying to XOR a 12-bits long message against an 8-bits long key.
Method of wrapping the key that seems to work (when scaled-up and used against a 269-bit long encrypted message) is the following:
message = "110111101010"
key = "01100001"
def adjust_key_length(message, key):
multiplier = len(message) / len(key)
modulo = len(message) % len(key)
adjusted_key = key[0:modulo] + key * multiplier
return adjusted_key
Code above translates to:
multiplier = 1
modulo = 4
adjusted_key = "0110" + "01100001"
As I've said above, this method of adjusting the key length seems to work on an actual encrypted message, yielding a decrypted English plaintext, with one exception: The first ASCII character of the encrypted word seems to be missing, as the word reads "ooking".
I'm presuming it's supposed to be "cooking".
What is the right way to XOR a longer message against a one-byte key?