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 *utf8*
turn 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"=>"[email protected]"
);

$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?

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/a476efe4-87b4-429b-bb9e-8256ffb6fab3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to