Hello,
I am looking for 2 lines of code, one which will encrypt (using a shared key) a string in ASP and the other will decode the same string in PHP.
Can someone please suggest.
Hello,
I am looking for 2 lines of code, one which will encrypt (using a shared key) a string in ASP and the other will decode the same string in PHP.
Can someone please suggest.
You will need more than one line of code per language for that.
For ASP you can use a component called CAPICOM that is included with Windows, for PHP the encryption functions is among all other functions. The gotcha I remember from doing this is that the input to capicom is sent as unicode per default. Your best bet is probably to convert the unicode to ascii or something when you get it back from the decryption function in PHP.
Using standard APIs, I doubt it will be possible to do in two lines. So if "two lines" is a strict requirement, I recommend starting an external process. Make sure you have openssl installed on both systems, and use the 'openssl enc' command.
To encrypt, do
openssl enc -aes-256-cbc -salt -k PASSWORD -in /tmp/infile -out /tmp/encrypted
To decrypt, do
openssl enc -d -aes-256-cbc -salt -k PASSWORD -in /tmp/encrypted -out /tmp/decrypted