New packets, general Improvement

This commit is contained in:
Shoghi Cervantes Pueyo
2012-10-21 23:58:16 +02:00
parent 9c4abf49f5
commit 5425dfa5dc
7 changed files with 28 additions and 72 deletions

View File

@ -131,6 +131,17 @@ class Utils{
return ($negative === true ? "-":"").str_replace("x", "", $hash);
}
public static function hexdump($bin){
$output = "";
$bin = str_split($bin, 16);
foreach($bin as $counter => $line){
$hex = chunk_split(chunk_split(str_pad(bin2hex($line), 32, " ", STR_PAD_RIGHT), 2, " "), 24, " ");
$ascii = preg_replace('#([^\x20-\x7E])#', '.', $line);
$output .= str_pad(dechex($counter << 4), 4, "0", STR_PAD_LEFT). " " . $hex . " " . $ascii . PHP_EOL;
}
return $output;
}
public static function microtime(){
return microtime(true);