From 4481e9cc18f815414af32f99a02122bc5f57c2d1 Mon Sep 17 00:00:00 2001 From: Jethro Stapelbroek Date: Wed, 19 Jul 2023 20:40:14 +0200 Subject: [PATCH] Kleptography --- kleptography.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 kleptography.py diff --git a/kleptography.py b/kleptography.py new file mode 100644 index 0000000..0c4676e --- /dev/null +++ b/kleptography.py @@ -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))