> 8) ^ ord($data[$i])) & 0xFF; $x ^= $x >> 4; $crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF; } return $crc; } } /** * Dump out data into a hex dump */ if (! function_exists('hex_dump')) { function hex_dump($data,$newline="\n",$width=16) { $result = ''; $pad = '.'; # padding for non-visible characters $to = $from = ''; for ($i=0; $i<=0xFF; $i++) { $from .= chr($i); $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad; } $hex = str_split(bin2hex($data),$width*2); $chars = str_split(strtr($data,$from,$to),$width); $offset = 0; foreach ($hex as $i => $line) { $result .= sprintf('%08X: %-48s [%s]%s', $offset, substr_replace(implode(' ',str_split($line,2)),' ',8*3,0), $chars[$i], $newline); $offset += $width; } return $result; } }