Created
September 15, 2022 16:16
-
-
Save meicookies/4b6cb29811c0b730c1daf71cb0bfa763 to your computer and use it in GitHub Desktop.
Vigenère encryption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
a = string.ascii_lowercase | |
p = "mei" | |
k = "biru" | |
if len(k) > len(p): k = k[:len(p)] | |
if len(k) < len(p): | |
i = 0 | |
while len(k) != len(p): | |
k += k[i % len(k)] | |
i += 1 | |
pIndex = [a.index(char) for char in p if char.isalpha()] | |
kIndex = [a.index(char) for char in k if char.isalpha()] | |
index = [pIndex, kIndex] | |
index = [sum(a) % 26 for a in zip(*index)] | |
print(str().join([chr(i + 97) for i in index])) | |
# Vigenère cipher encryption coded by meicookies |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment