Skip to content

Instantly share code, notes, and snippets.

@0awawa0
Created April 6, 2021 07:33
Show Gist options
  • Save 0awawa0/8e669c8a9cb06f2eae16a49df355a83b to your computer and use it in GitHub Desktop.
Save 0awawa0/8e669c8a9cb06f2eae16a49df355a83b to your computer and use it in GitHub Desktop.
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