Hi all,
I have a problem coding an "encryption" method. What this code should do is read all the letters from a string and replace it with other characters. Think of it as a secret language where a's are written as x's and b's are written like f's and so on...
Here's the source:
$encrypted = array("0", "9", "8", "7", "6", "5", "4", "3", "2", "1", "Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A", "z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b", "a", "_", " ");
$decrypted = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ," ", "_");
$encrypt = str_replace($encrypted,$decrypted,$_POST['enc']);
$decrypt = str_replace($decrypted,$encrypted,$_POST['dec']);
It works OK, but only for lowercase letters. When I try to encrypt uppercase letters, it just keeps the uppercase letters on their original position and doesn't change it at all. Decrypting does work though, very weird.
What am I overlooking ?