- chr: documentation ( source)
- str_split: documentation ( source)
- ord: documentation ( source)
<?php
$string = "hello, this is evening, and this is SO";
$key = 21344124124214124324512124124;
function encrypt( $text, $xorKey ) {
$xored = '';
$chars = str_split( $text );
$i = 0;
while ( $i < count( $chars ) ) {
$xored .= chr( ord( $chars[$i] ) ^ $xorKey );
$i++;
}
return $xored;
}
$encrypted = encrypt($string, $key);
echo $encrypted; // hello, this is evening, and this is SO