Kleptography

This commit is contained in:
2023-07-19 20:40:14 +02:00
parent 022eaf7a60
commit 4481e9cc18

13
kleptography.py Normal file
View File

@@ -0,0 +1,13 @@
n, m = map(int, input().split())
knowntext = input()
ciphertext = input()
plaintext = [""] * m
for i in range(n):
plaintext[-n + i] = knowntext[i]
for i in range(m - 1, -1, -1):
char = chr((ord(ciphertext[i]) - ord(plaintext[i])) % 26 + 97)
if i - n >= 0:
plaintext[i - n] = char
print("".join(plaintext))