Упрощаем для модераторов понимание символа ^ :)
define("SALT","gfklhjr09j5FDGfkj49llkrjltreGuxLWQtKweKEMV4");
define("PASSWORD","ejhjkerht9348hhjkehtkjer");
function encode($String, $Password,$Salt) {
$StrLen = strlen($String);
$Seq = $Password;
$Gamma = '';
while (strlen($Gamma)<$StrLen)
{
$Seq = pack("H*",sha1($Gamma.$Seq.$Salt));
$Gamma.=substr($Seq,0,8);
}
return $String^$Gamma;
}
$s='this is test string';
$enc=encode($s,PASSWORD,SALT);
$dec=encode($enc,PASSWORD,SALT);
echo 'Original string: '.$s.'<br>';
echo 'Encrypted string: '.base64_encode($enc).'<br>';
echo 'Decrypted string: '.$dec.'<br>';