In <[email protected]> [email protected] 
writes:

> """ crypto.py
>     Implements a simple substitution cypher
> """

> alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> key =   "XPMGTDHLYONZBWEARKJUFSCIQV"

> 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..."

> i really need help on how to encrypt it im not sure how to go about doing
> that please help.

def encode(plain):
   '''Return a substituted version of the plain text.'''

   encoded = ''

   for ch in plain:
      encoded += key[alpha.index(ch)]

   return encoded

-- 
John Gordon                   A is for Amy, who fell down the stairs
[email protected]              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to