Decode
28-10-2008, 04:59 PM
I've made a code that muddles up letters and numbers, but it just won't work. I've been looking at it for like 15 minutes and I can't figure out whats wrong :S
<?php
$normal = 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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"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", " ",
);
$mixed = array(
"h", "c", "a", "E", "9", "z", "N", "F", "7", "O", "8", "P",
"D", "6", "5", "x", "0", "y", "H", "G", "g", "L", "p", "S",
"o", "w", "n", "v", "b", "A", " ", "j", "M", "i", "K", "k",
"R", "l", "4", "3", "r", "Q", "u", "e", "f", "2", "1", "T",
"t", "C", "m", "U", "W", "J", "d", "I", "q", "Z", "V", "X",
"Y", "s", "B",
);
if ( isset ( $_GET['encode'] ) ) {
$data = $_GET['encode'];
$data = str_replace( $mixed, $normal, $data );
}
else if ( isset ( $_GET['decode'] ) ) {
$data = $_GET['decode'];
$data = str_replace( $normal, $mixed, $data );
}
echo $data;
?>
Any ideas whats wrong?
<?php
$normal = 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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"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", " ",
);
$mixed = array(
"h", "c", "a", "E", "9", "z", "N", "F", "7", "O", "8", "P",
"D", "6", "5", "x", "0", "y", "H", "G", "g", "L", "p", "S",
"o", "w", "n", "v", "b", "A", " ", "j", "M", "i", "K", "k",
"R", "l", "4", "3", "r", "Q", "u", "e", "f", "2", "1", "T",
"t", "C", "m", "U", "W", "J", "d", "I", "q", "Z", "V", "X",
"Y", "s", "B",
);
if ( isset ( $_GET['encode'] ) ) {
$data = $_GET['encode'];
$data = str_replace( $mixed, $normal, $data );
}
else if ( isset ( $_GET['decode'] ) ) {
$data = $_GET['decode'];
$data = str_replace( $normal, $mixed, $data );
}
echo $data;
?>
Any ideas whats wrong?