Created
April 6, 2021 07:33
-
-
Save 0awawa0/8e669c8a9cb06f2eae16a49df355a83b to your computer and use it in GitHub Desktop.
This file contains 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 | |
with open("key.txt", "r") as f: | |
shift = int(f.readline()) | |
key = f.readline() | |
with open("flag.txt", "r") as f: | |
flag = f.read() | |
stdalph = string.ascii_lowercase | |
rkey = "" | |
for i in key: | |
if i not in rkey: | |
rkey += i | |
for i in stdalph: | |
if i not in rkey: | |
rkey += i | |
rkey = rkey[-shift:] + rkey[:-shift] | |
enc = "" | |
for a in flag: | |
if a in stdalph: | |
enc += rkey[stdalph.index(a)] | |
else: | |
enc += a | |
print(enc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment