I am having a problem decrypting some files via the OpenSSL plugin.
I have some JSON files that I am encrypting on my Mac using this command line in Terminal:
openssl enc -aes-256-cbc -salt -in default.json -out default.enc
In my app, I have this:
local json = require( "json" ) local openssl = require( "plugin.openssl" ) local cipher = openssl.get\_cipher ( "aes-256-cbc" ) local jsonFile = function( filename, base ) if not base then base = system.ResourceDirectory end local jsonFilePath = system.pathForFile( filename, base ) local jsonFileContents local file = io.open( jsonFilePath, "r" ) if file then jsonFileContents = file:read( "\*a" ) io.close( file ) end return jsonFileContents end dta = {} dta = json.decode(cipher:decrypt(jsonFile("Assets/default.enc", system.ResourceDirectory), "Password"))
The password is the one that I am entering on the Mac to encrypt the files.
But when I try to access the data, I get this error:
Attempt to index upvalue ‘dta’ (a nil value)
This is my first time working with encrypted data – which I am only doing so as to not make it easy for someone to steal my game’s content – so not sure if I am doing something wrong in encrypting the data or my use of the plugin.
I did break the dta = json.decode(cipher:decrypt(jsonFile(“Assets/default.enc”, system.ResourceDirectory), “Password”)) line up so that I could see the data at each step of the decoding. And the cipher:decrypt portion is not decrypting the data correctly into the JSON structure.
Anyone have any ideas?