Is there any safe crypting algorithm that you can I can use this way?
<?php
$message="Hi there!";
$key1="ablablabla";
$key2="fooboomoohoo";
$tmp=encrypt($message,$key1);
$tmp=encrypt($tmp,$key2);
$tmp=decrypt($tmp,$key1);
$result=decrypt($tmp,$key2);
echo "\"".$message."\" is the same as \"".$result."\"";
?>
It should work like this:
-
User wants to send an encrypted message to server, so he encrypts it with his secret key
-
Server gets an encrypted message, so he encrypts it again with it’s own secret key and sends it back
-
User decrypts the message with his key and sends it back
-
Finally, the server decodes the message
What about a stream cipher like RC4?
Encryption and decryption involve XOR with the output of a PRNG. (Actually decryption is the same as encryption.)