when i say basic i mean basic it doesnt store the encrypted string in a file or anything it just prints out what it would be and all i intend it to do is swap a for b, b for c and so on then turn the string round backwards once its done that. and the decrypt would be turinng it round backwards again then changing b to a, c to b etc. anyway i have forgotten how to turn the string round backwards allthough i am pretty sure it has something to do with slicing like
a = pie
b = a[3:0]
print a
print b
with my expetced output being
pie
eip
and with the actual output being
pie
[this is a blank line]
anyway if someone can help with that or if you have a better method that would be great, anyway here is the code.
#simple encryption program
import os
list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a']
choice = 0
while choice != 2:
os.system("cls")
print "Encryption/Decryption Program"
print "-" * 10
print "0 - Encrypt Text"
print "1 - Decrypt Text"
print "2 - Quit"
choice = input("Choose: ")
if choice == 0:
print "Enter the string to be encrypted below"
text = raw_input()
for letter in range(1,27):
letter2 = letter + 1
text.replace(list[letter], letter2)
print "Your text encrypted is",text
elif choice == 1:
print "Enter the string to be decyrpted below"
text = raw_input()
for letter in range(27,1):
letter2 = letter - 1
text.replace(list[letter], letter2)
print "Your text decrypted is ",text
elif choice == 2:
print "Bye"
else:
print "Please enter either 0,1 or 2"
raw_input()
#End
The problem is on this line
text.replace(list[letter], letter2)
and the error i get is
Traceback (most recent call last):
File "C:\Python25\Decrypt_Encrypt.py", line 20, in <module>
text.replace(list[letter], letter2)
TypeError: expected a character buffer object
i might just be using the wrong command or syntax or this might just not work at all and iam being a idiot but either way ied like help with this. thanks.