Hi,
I’m having problems with the openssl, mime encoding and PHP. Following the instructions on this post: http://coronalabs.com/blog/2013/06/11/tutorial-using-the-openssl-plugin/ , this is what I get:
-
At Corona side:
local openssl = require “plugin.openssl” local cipher = openssl.get_cipher ( “aes-256-cbc” ) local mime = require ( “mime” ) local encryptedData = mime.b64 ( cipher:encrypt ( “Your Text Here”, “Your Key Here” ) ) local decryptedData = cipher:decrypt ( mime.unb64 ( encryptedData ), “Your Key Here” ) print ( "Encrypted Text: " … encryptedData ) – VS3oMYuhWEEjr7UY8N5xAQ== print ( "Decrypted Text: " … decryptedData ) – Your Text Here local testParams = { body = “encryptedData=” … encryptedData } network.request( url … “test.php”, “POST”, networkListener, testParams)
-
At server side:
<?php $source = ‘Your Encrypted Text Here’; $pass = ‘Your Key here’; $method = ‘aes-256-cbc’; echo "test : " .$_POST[‘encryptedData’]; // VS3oMYuhWEEjr7UY8N5xAQ== $encrypted = base64_encode ( openssl_encrypt ( $source, $method, $pass ) ); echo "encrypted : " .$encrypted; // RjhPVG9NVkVrbHQrckR6S1hnMmd0TW1tcmRtNHc1STZYSHNxMExwT1dEND0= $decrypted = openssl_decrypt ( base64_decode ( $encrypted ), $method, $pass ); echo "decrypted : " .$decrypted; // ‘Your Encrypted Text Here’ $decrypted2 = openssl_decrypt ( base64_decode ( $_POST[‘encryptedData’] ), $method, $pass ); echo "decrypted2 : " .$decrypted2; // ‘’ ?>
As you can see, the encryption results at local and server side are completely different. This is driving me crazy. I want to send data encrypted from my app to the server to connect to a database and perform queries and so.
Do you know what I’m doing wrong?
Thanks a lot!!