Cryptography Help

0 comments

“”” crypto.py
  Implements a simple substitution cypher
“””

alpha = “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
key =  “XPMGTDHLYONZBWEARKJUFSCIQV”
result = “”

def main():
  keepGoing = True
  while keepGoing:
  response = menu()
  if response == “1”:
  plain = raw_input(“text to be encoded: “)
  print encode(plain)
  elif response == “2”:
  coded = raw_input(“code to be decyphered: “)
  print decode(coded)
  elif response == “0”:
  print “Thanks for doing secret spy stuff with me.”
  keepGoing = False
  else:
  print “I don’t know what you want to do…”

#Define the menu
def menu():
   
  #print out the menu
  print (“SECRET DECODER MENUnn 0) Quitn 1) Encoden 2) DecodennWhat do you want to do?”)
   
  #take in user respose and return it
  userResponse = raw_input()
  return userResponse

#define the encoder
def encode(plain):
  #For loop to find the letters in plain
  for letters in plain:
  #find the same letters in alpha and set as location
  location = letters.find(alpha)
  #find the same location in the key
  result = key[location]
  return
main()

How do I make this work?

<br>

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}