I am trying to make a low level encryption, my current code for it is...
<?php
function encryption($string, $char='e') {
$array = array(A => "m", B=>"F", C=>"t", D=>"K", E=>"3", F=>"Q", G=>"2", H=>"z", I=>"c", J=>"A", K=>"i", L=>"x", M=>"0",
N=>"Z", O=>"a", P=>"L", Q=>"p", R=>"H", S=>"7", T=>"1", U=>"e", V=>"T", W=>"g", X=>"l", Y=>"C", Z=>"W",
a=>"B", b=>"f", c=>"O", d=>"w", e=>"r", f=>"y", g=>"5", h=>"o", i=>"G", j=>"X", k=>"u", l=>"k", m=>"9",
n=>"v", o=>"J", p=>"R", q=>"S", r=>"b", s=>"D", t=>"N", u=>"P", v=>"6", w=>"q", x=>"S", y=>"h", z=>"E",
1=>"I", 2=>"V", 3=>"Y", 4=>"d", 5=>"4", 6=>"8", 7=>"M", 8=>"j", 9=>"U", 0=>"n", " "=>"ß", "ß"=>" "
);
for ($x = 0; $x < strlen($string); $x++) {
if ($char == 'e') $replace = $array[$string[$x]];
if ($char == 'd') { foreach ($array as $key=>$value) { if ($value == $string[$x]) { $replace = $key; } } }
$string[$x] = str_replace($string[$x], $replace, $string[$x]);
}
return $string;
}
?>
Now my code to use it is...
$e = encryption("Hello World, My Name is Josh Weißböck");
$d = encryption($e, 'd');
$content = "Encrypted: $e<br>Decrypted: $d";
Now echoing the variable this is what I get for a result...
Encrypted: zrkkJßgJbkwß0hßZB9rßGDßAJDoßgrG fOu
Decrypted: Hello Worldd My Name is Josh Weißbbck
Which is not exactly the same, and I can not figure out how to get it to work correctly.