function myfunc($text){
$text = utf8_encode($text);
$buffer = [];
foreach(mb_str_split($text) as $v)
$buffer[] = ord($v);
for ($i = count($buffer)-2; $i >= 0; $i--)
$buffer[$i] ^= $buffer[$i+1];
$buffer[count($buffer) - 1] ^= $buffer[0];
return implode(array_map("dec2hexbyte", $buffer));
}
function dec2hexbyte($number){
$hexval = dechex($number);
if(mb_strlen($hexval) == 1)
$hexval = "0".$hexval;
return mb_strtoupper($hexval);
}
$text = "my text";
echo myfunc($text);