I have found a module pycrypto which has an AES encryption and decryption function, in commandline everything works fine both encryption and decryption,
but if I want to implement it in my program, it fails =(
def aes(txt):
global crypt
message="".join(txt) #format the message which has to be encrypted/decrypted to a string
c=0
plist="".join(pflist)
while len(plist)<15:
plist+="a"
c+=1
#loop is to be sure the password has at least 16 characters.
plist+=str(c)
obj=AES.new(plist[:16], AES.MODE_ECB)
if crypt == "en":
c=0
while len(message)/16 != len(message)//16:
message+="a"
c+=1
#loop is to be sure the message is a multiple of 16
ciphertext=obj.encrypt(message)
else:
print message,len(message)
ciphertext=obj.decrypt(message)
return ciphertext
The encryption system succeeds, but the decryption system fails
if I decrypt it with \xb4\xe0\xa0LH/\xefO\xc9|y7&"Af
the program says it has a length of 31 (which strictly seen is also true),
but if you do the following in command line it will say that the length is 16
string='\xb4\xe0\xa0LH/\xefO\xc9|y7&"Af'
len(string)
I don't know what's wrong... I think it has to do something with the type in which the \xb4\xe0\xa0LH/\xefO\xc9|y7&"Af is passed but I'm not sure...