Spent my morning on this, not much closer really, I need some ninja help.
I’m encoding and decoding strings excatly like described here: http://www.coronalabs.com/blog/2013/06/11/tutorial-using-the-openssl-plugin/
Code below produces error
Runtime error: main.lua:15: bad argument #1 to ‘decrypt’ (string expected, got nil)
The interesting thing is if you change the key or str code works fine. So the the combination of that key and string is fatal and causes an error in about 1/200 games for me. Not good!
[lua]local openssl = require(“plugin.openssl”)
local cipher = openssl.get_cipher ( “aes-256-cbc” )
local mime = require(“mime”)
local key = “abc”
local str = ‘AHTSTD4H7S2C8S2D7H’
local encrypted = cipher:encrypt(str, key)
print(“encrypted”, encrypted)
local encryptedB64 = mime.b64(encrypted)
print(“encryptedB64”, encryptedB64)
– Now decrypt
local unpacked64 = mime.unb64(encryptedB64)
local decrypted = cipher:decrypt(unpacked64, key)
print(“decrypted”, decrypted)
[/lua]
One interesting thing is that the “print(“encrypted”, encrypted)” line does not print anything in above case, while it prints some characters if you change the str variable.