I'm making an encoding function, but it went wrong already. I know that this would be very easy to crack, but it will become a lot more complicated later on.
Pretty much, the code declares the variables, changes them into arrays, and uses Str_replace to replace all instances in $_GET['x'] with another. "a" with "f", "b" with "c", etc.
But, it doesn't work that way. When I tell it to encode "a", it returns "2". When I try to encode "abcdef", I get "2U#dt2", instead of the results I wanted, which is "f)tIk^". Thanks.
Pretty much, the code declares the variables, changes them into arrays, and uses Str_replace to replace all instances in $_GET['x'] with another. "a" with "f", "b" with "c", etc.
But, it doesn't work that way. When I tell it to encode "a", it returns "2". When I try to encode "abcdef", I get "2U#dt2", instead of the results I wanted, which is "f)tIk^". Thanks.
Code:
<?
$abc = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+=";
$key = "f)tIk^PQoOhzNJw9-_6ebs!4pxRaEqT$U2LWd07FGl&BZVy3+7#rm=M%5*jYXvD(AcHu1CKn@IgS";
for($i=0; $i < strlen($abc); $i++) {
$x = $i + 1;
$abc_array[] = substr($abc, $i, 1);
$key_array[] = substr($key, $i, 1);
}
$enmsg = str_replace($key_array, $abc_array, $_GET['x']);
echo $enmsg;
?>