Skip to content

Instantly share code, notes, and snippets.

@evernick
Created June 17, 2015 06:41
Show Gist options
  • Save evernick/e4e09624f46952606dcd to your computer and use it in GitHub Desktop.
Save evernick/e4e09624f46952606dcd to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import sys
def decode(alphabet,ciphertext,key):
dic={}
for i in range(0,len(key)):
dic[key[i]]=alphabet[i]
plaintext=""
for l in ciphertext:
if l in dic:
l=dic[l]
plaintext+=l
return plaintext
if __name__ == "__main__":
f = open('a.txt', "rb")
ciphertext = f.read()
print decode("abcdefghijklmnopqrstuvwxyz", ciphertext, "nopqrstuvwxyzabcdefghijklm")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment