Hi, I have a weird problem.
I am encrypting a table and saving it in my documents directory:
local openssl = require “plugin.openssl”
local cipher = openssl.get_cipher ( “aes-256-cbc” )
local mime = require ( “mime” )
local deviceID = system.getInfo( “deviceID” ) or ( _G.iOSappID )
local contents = json.encode( t )
local encryptedData = mime.b64 ( cipher:encrypt ( contents, deviceID ) )
if _G.encryptedSaveData then
file:write( encryptedData )
else
file:write( contents )
I read it back in with:
local contents = file:read( “*a” )
local decryptedData = cipher:decrypt ( mime.unb64 ( contents ), deviceID )
local t = {}
if _G.encryptedSaveData then
t = json.decode( decryptedData );
else
t = json.decode( contents );
My problem is when encrypting is on, I get an error "attempt to index global ‘tablename’ (a nil value), but only in a function that I call that uses thetable. If I use the table directly in the code right after loading it, it works fine.
When I turn encryption off and run the same code, there is no error. When I print out the table created with encryption and without encryption they are identical.
So somehow the scope of my table is getting blown away when I turn encryption on!
Any help is greatly appreciated as I don’t want to release my game with clear text settings!, Greg