Advertisement
Guest User

Python project

a guest
Nov 28th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. def cipher(input):
  2.     cryptic = dict()
  3.     infile = open(input, "r")
  4.     for line in infile:
  5.         whole = line.split()
  6.         parts = whole[0]
  7.         key = whole[1]
  8.         cryptic[parts] = key
  9.     infile.close()
  10.     return cryptic
  11.  
  12. def replaceText(input, cryptic):
  13.     infile = open(input, "r")
  14.     decrypted = ""
  15.     for line in infile:
  16.         for parts in line:
  17.             if parts in cryptic:
  18.                 decrypted += cryptic[parts]
  19.             else:
  20.                 decrypted += parts
  21.     infile.close()
  22.  
  23. key = cipher("key.txt")
  24. decode = replaceText("encypted.text",key)
  25. outfile = open("decrypted.txt", "w")
  26. outfile.write(decode + "\n &nbsp")
  27. outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement