Hi -
I am working on a API that is written in node.js and i was given a node.js sample code and have to write that in PHP. Having 0 coding knowledge for node.js... I am looking for HELP.
Here is the code i have:
var crypto = require('crypto);
var thisCipher = crypto.createCipher("aes-128-cbc", secret);
var encryptedData = thisCipher.update(data, 'utf8', 'hex');
encryptedData += thisCipher.final('hex');
return encryptedData;
The above is how any data is encrypted on the program.
I am trying to use openSSL in PHP
http://php.net/manual/en/function.openssl-encrypt.php... but not getting in success.
Here is what we want to be able to do in general.
Encrypt a json encoded string using
AES-128-CBC method.
make sure it's
utf8turn it into a
hexadecimal.
post it.
So far i am using...
$bag = array(
"firstName"=>"Name",
"lastName"=>"Last",
"address1"=>"Address",
"address2"=>"Apt. 34",
"city"=>"City",
"state"=>"State",
"zipCode"=>"123456",
"email"=>"te...@gmail.com"
);
$string = json_encode($bag);
$key = '123456789123456789123456789';
$method='aes-128-cbc';
$ciphertext = bin2hex(openssl_encrypt($string, $method , $key));
echo $ciphertext;But this is not working.
tips?