I am using encryptString function to add some protection to the information I read/write on the fly. But decryptString is yielding unstable results.
Here is the code I use to read / write files.
import os, sys
from panda3d.core import Filename, encryptString, decryptString
password='my_password'
myfile=Filename.fromOsSpecific(os.path.join(myDir,'temp.txt')).getFullpath()
## write
with open(myfile,'w') as tempFile:
string=' text_to_write'
tempFile.write(encryptString(string, password))
print 'original message: '+string
## read
string=open(myfile, 'rU').read()
string=decryptString(string,password)
print 'decrypted message: '+string
sys.exit()
Everything works fine when I run this from terminal on Mac 10.11, Panda 1.9.2, but when I pack it into p3d and run that (on the same machine) decryption fails and gives me a wonky string.
Also the code works fine on strings up to a certain length, for instance string1 works and string2 breaks:
string1='aux_values*4,0,0.5,0.5*'
string2='*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*'
Here is log:
original message: *aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5**
:prc(error): Error decrypting stream.
decrypted message: *aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aux_values*4,0,0.5,0.5*aue§9¸³-F6lÄB,ly%á¦CeßgáúÀÔ ¤Ðt
:AppRunner: Normal exit with status None.
Any idea what I’m doing wrong, or if this is a bug, or if there is a maximum length that decryptString works on (that encryptString does not have)?