$theString = "AAAACCCC";
$encrypted = encrypt($theString);
echo "The encrypted version of {$theString} is {$encrypted}
\n";
echo "Now we will test the decrypt function
\n";
$decrypted = decrypt($encrypted);
echo "The decrypted version of {$encrypted} is {$decrypted}";
function encrypt($string)
{
// replace all A's with B's and all C's with D's
$string = str_replace('A', 'B', $string);
$string = str_replace('C', 'D', $string);
return($string);
}
function decrypt($string)
{
// to decrypt all we have to do is replace all B's with A's and all D's with C's
$string = str_replace('B', 'A', $string);
$string = str_replace('D', 'C', $string);
return($string);
}
?>