php code encode decode string

Encode Decode String

example———————————

$r=base64_encode(encode(“vishv sahdev”));
echo “<br>”.$r;
$r=decode(base64_decode($r));
echo “<br>”.$r;

————————————————————-

$r=encode(“vishv sahdev”);
echo “<br>”.$r;
$r=decode($r);
echo “<br>”.$r;

——————————————————————

function encode($r){

$n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789-";
$convert = 'y1xYsKjeXT7o3iHrCVz0uwLFtWcPbD4kMahdNAIJ5En-pGfOUQBq9m6v28RgZlS';
$numbers1 = str_split($r);
$f=array_combine(str_split($n), str_split($convert));
$x='';
foreach($numbers1 as $k=>$v)
if(isset($f[$v]))
$x .= $f[$v];
else
$x .= $v;
return $x;
}

function decode($r){
$n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcedfghijklmnopqrstuvwxyz0123456789-";
$convert = 'y1xYsKjeXT7o3iHrCVz0uwLFtWcPbD4kMahdNAIJ5En-pGfOUQBq9m6v28RgZlS';
$numbers1 = str_split($r);
$f=array_combine(str_split($n), str_split($convert));
$f=array_flip($f);
$x='';
foreach($numbers1 as $k=>$v){
if(isset($f[$v]))
$x .= $f[$v];
else
$x .= $v;
}
return $x;
}

generate password php code

Generate Password
function generate_password(){
$chars[0] = "abcdeghijklmnpqrstvwxyz"; // 4 chars
$chars[1] = "ABCDEFGHIJKLMNPQSTVWXYZ"; // 2 chars
$chars[2] = "012345789"; // 2chars
$chars[3] = "$#@!%^&*_-+"; // 2chars
$cc=[4,2,2,2];  //
for($g=0;$g<4;$g++){
for($i=0;$i<$cc[$g];$i++){
$key[]= substr($chars[$g],(rand()%(strlen($chars[$g]))), 1);
}
}
shuffle($key);
return implode("",$key);
}