psCheckSum() XOR Checksum
Description:
Returns an XOR checksum in hex
Usage:
$chkSum = psCheckSum($str);
Example:
$str="this is a test"; $chkSum = psCheckSum($str);
Code:
function psCheckSum($str) { $chk = 0; for($k = 0; $k < strlen($str); $k++) { $o = ord(substr($str,$k,1)); $chk = $chk ^ $o; } $res = substr("0" . dechex($chk),-2); return $res; }
Changlelog:
|
|