There is a one time pad which works as follows: given message "hello" and key "asdfg", it produces "hwoqu". It only works with the 26 english letters. The output is (h(7) + a(0))%26 = h(7), (e(4) + s(18))%26 = w(22) etc.
So I have two ciphertexts created as above using a single key for both ciphertexts. I'm supposed to be able to crack the plain texts without needing access to the key.
What is the procedure to do this?
So far, I've tried XORing the two cipher texts, i.e. for each letter in c1 and c2, convert to its corresponding numeric value and XOR the nth letter of c1 with nth letter of c2, to genate c3.
I'm then supposed to use that with a guess word like "the" by exoring that against c3. This is the part where I'm stuck, I don't know what I'm supposed to be looking for here.
Edit:
So since its a addition rather than a XOR, this is what I wrote:
c1 = "ujhantamawmuzvgkterrykub"
c2 = "bpgxmkymbbpyxmogoehdefgh"
pad encrypt and decrypt:
def oneTimePad(message, code):
message_out = ""
for i in range(len(message)):
index = (letters.find(message[i]) + letters.find(code[i]))%26
message_out+= letters[index]
return message_out
def otpDecrypt(cipher, key):
message_out = ""
for i in range(len(key)):
index = (letters.find(cipher[i]) - letters.find(key[i]))%26
message_out+= letters[index]
return message_out
the cracker:
def padCracker(m1, m2, guess): # m1, m2 list of nums
m3 = list(map(lambda x, y: (x + y) %26, m1, m2))
check = [] # m3 + guess mod 26
guessNum = list(map(lambda c : letters.find(c), guess))
for i in range(len(m3)-len(guess)+1):
check = list(map(lambda x, y: (x+y)%26, guessNum, m3[i: i+len(guess)]))
print(check, end="")
string = ""
for num in check:
string += letters[num]
print(string)
print(padCracker(m1,m2, "bcd"))
this suggests that c1 starts with "the" and c2 with "and" with key "bcd" but I don't know how to get the rest of the key
So, what is the procedure to then undo the vigenere cipher, and how do I use the relationship between c1 and c2 to get at the plaintext?
– Shiny_and_Chrome Oct 25 '21 at 01:00If I understand crib dragging correctly, I take a guess word like "the" or "and" or "have", convert it to its numerical value then add each letter to the corresponding letter in the c3, if the result is something readable, then that gives me another potential guess word to then build up what the message is.
– Shiny_and_Chrome Oct 25 '21 at 01:20The whole crib thing is not clicking.
I've updated my original post to show what I tried.
– Shiny_and_Chrome Oct 25 '21 at 03:55