-
-
Save Toastdude/6307144ff402dfbd0d7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code is based off of forum post from user "vegaseat" on http://www.daniweb.com/software-development/python/threads/63552 | |
def choice(): | |
print '1) Encrypt Text'; | |
print '2) Decrypt Text'; | |
print '3) Exit'; | |
choose = input("Enter Choice: "); | |
if choose == 1: | |
En(); | |
elif choose == 2: | |
De(); | |
elif choose == 3: | |
print 'Bye!'; | |
else: | |
print 'Enter valid choice.'; | |
print; | |
choice(); | |
def En(): | |
str1 = raw_input("Enter text to be encoded: "); | |
encodedstr1 = str1.encode('rot13'); | |
encodedstr2 = list(encodedstr1) | |
encodedstr2.reverse() | |
encodedstr2[0:] = [''.join(encodedstr2[0:])] | |
print "Encoded text: ", encodedstr2; | |
print; | |
raw_input("Press <Enter>"); | |
print; | |
choice(); | |
def De(): | |
str1 = raw_input("Enter text to be decoded: "); | |
decodedstr1 = str1.encode('rot13'); | |
decodedstr2 = list(decodedstr1); | |
decodedstr2.reverse(); | |
decodedstr2[0:] = [''.join(decodedstr2[0:])]; | |
print "Decoded text: ", decodedstr2; | |
print; | |
raw_input("Press <Enter>"); | |
print; | |
choice(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On line 27 and 41, you don't actually need to use [0:], you can do [:] and it will still work - the 0 is assumed, if you don't put anything in.