@ 2015-11-27T05:37:16Z <?php
/**
* View any string as a hexdump.
*
* This is most commonly used to view binary data from streams
* or sockets while debugging, but can be used to view any string
* with non-viewable characters.
*
* @version 1.3.2
* @author Aidan Lister <aidan@php.net>
* @author Peter Waller <iridum@php.net>
* @link http://aidanlister.com/2004/04/viewing-binary-data-as-a-hexdump-in-php/
* @param string $data The string to be dumped
* @param bool $htmloutput Set to false for non-HTML output
* @param bool $uppercase Set to true for uppercase hex
* @param bool $return Set to true to return the dump
*/
function hexdump ($data, $htmloutput = false, $uppercase = false, $return = true)
{
// Init
$hexi = '';
$ascii = '';
$dump = ($htmloutput === true) ? '<pre>' : '';
$offset = 0;
$len = strlen($data);
// Upper or lower case hexadecimal
$x = ($uppercase === false) ? 'x' : 'X';
// Iterate string
for ($i = $j = 0; $i < $len; $i++)
{
// Convert to hexidecimal
$hexi .= sprintf("%02$x ", ord($data[$i]));
// Replace non-viewable bytes with '.'
if (ord($data[$i]) >= 32) {
$ascii .= ($htmloutput === true) ?
htmlentities($data[$i]) :
$data[$i];
} else {
$ascii .= '.';
}
// Add extra column spacing
if ($j === 7) {
$hexi .= ' ';
$ascii .= ' ';
}
// Add row
if (++$j === 16 || $i === $len - 1) {
// Join the hexi / ascii output
$dump .= sprintf("%04$x %-49s %s", $offset, $hexi, $ascii);
// Reset vars
$hexi = $ascii = '';
$offset += 16;
$j = 0;
// Add newline
if ($i !== $len - 1) {
$dump .= "\n";
}
}
}
// Finish dump
$dump .= $htmloutput === true ?
'</pre>' :
'';
$dump .= "\n";
// Output method
if ($return === false) {
echo $dump;
} else {
return $dump;
}
}
$row=array_fill(0,256*4,'U');
$mem_map=array_fill(0,100,$row);
$output="";
$mypic=imagecreate(100,100);
$mycolor=imagecolorallocate($mypic,4,5,6);
$mycolor2=imagecolorallocate($mypic,0x111,0x111,0x111);
imagefill($mypic,0,0,$mycolor2);
$pic_map=array_fill(0,100,$mypic);
for ($x=0;$x<256*60;$x++){ //Each x is 1 index
$cur_row=(int)($x/256);
$offset=($x%256)*4;
//if($offset!=0)die("offset not zero");
//print "True color image[b4] =" . (imageistruecolor($mypic)) ."\n";
//$mypic2=imagerotate($mypic,30,256*13 + $x);
//$mypic2=imagerotate($pic_map[$cur_row],30,$x);
$mypic2=imagerotate($mypic,30, $x);
// Byte @ 0
$mem_map[$cur_row+2][$offset]=imagecolorat($mypic2,0,0)&0xFF;
//echo "Row[$cur_row]-byte0\n";
//byte @ pos 1
if ($mem_map[$cur_row+1][$offset]!=='U'){
$Green=$mem_map[$cur_row+1][$offset];
$byte=(imagecolorat($mypic2,0,0)&0xFF00)>>8;
if($Green > $byte) $byte=$byte|0x100;
$mem_map[$cur_row+2][$offset+1]=($byte-$Green);
//echo "Row[$cur_row]-byte1\n";
}
else{
//echo "!=Row[$cur_row][$offset]=" . $mem_map[$cur_row+1][$offset]."\n";
}
//Byte @ POS 2
if(($mem_map[$cur_row+1][$offset+1]!=='U')&&($mem_map[$cur_row][$offset]!=='U')){
$Green=$mem_map[$cur_row+1][$offset+1];
$Red=$mem_map[$cur_row][$offset];
//if($cur_row==20){ echo "ROW20: RED=$Red , Green=$Green Byte=$byte"};
$byte=(imagecolorat($mypic2,0,0)>>16) &0xFF;
//if($cur_row==39){ echo "ROW20: RED=$Red , Green=$Green Byte=$byte \n";}
if($Green > $byte) $byte=$byte|0x100;
$byte=$byte-$Green;
if($Red > $byte) $byte=$byte|0x100;
$byte=$byte-$Red;
$OF_Flag=(($mem_map[$cur_row+1][$offset] + $mem_map[$cur_row+2][$offset+1])>0xff)?1:0;
$mem_map[$cur_row+2][$offset+2]=$byte - $OF_Flag;
//echo "Row[$cur_row]-byte2\n";
//var_dump($mem_map);
//die("post2die row=$cur_row");
// if($cur_row==39){echo "Row20:FinalBye=$byte\n";}
//hexdump(chr($mem_map[$cur_row+2][$offset]).chr($mem_map[$cur_row+2][$offset+1]).chr($mem_map[$cur_row+2][$offset+2]));
}
//Byte @ POS 3
if(($mem_map[$cur_row+1][$offset+2]!=='U')&&($mem_map[$cur_row][$offset+1]!=='U')){
$Green=$mem_map[$cur_row+1][$offset+2];
$Red=$mem_map[$cur_row][$offset+1];
$byte=(imagecolorat($mypic2,0,0)&0xFF000000)>>24;
if($Green > $byte) $byte=$byte|0x100;
$byte=$byte-$Green;
if($Red > $byte) $byte=$byte|0x100;
$byte=$byte-$Red;
$OF_Flag=(($mem_map[$cur_row][$offset] + $mem_map[$cur_row+1][$offset+1] + $mem_map[$cur_row+2][$offset+2])>>8)&0xFF;
$mem_map[$cur_row+2][$offset+3]=$byte -$OF_Flag;
//print "Current row = $cur_row\nCurrent offset =$offset";
//hexdump(chr($mem_map[$cur_row+2][$offset]).chr($mem_map[$cur_row+2][$offset+1]).chr($mem_map[$cur_row+2][$offset+2]).chr($mem_map[$cur_row+2][$offset+3]));
}
//var_dump(imagecolorat($mypic,0,0));
//echo "color @ 50,50 :" . dechex(imagecolorat($mypic,50,50)) . "\n";
//var_dump(imagecolorat($mypic,99,99));
imagedestroy($mypic);
$mypic=imagecreate(100,100);
imagefill($mypic,0,0,$mycolor2);
}
echo "done!\n";
//var_dump($mem_map);
$output="";
foreach($mem_map as $row){
foreach($row as $byte){
$output.=chr($byte);
}
}
for($count=0;$count<strlen($output);$count++){
if ($count%4 !=3) continue;
$byte=ord($output[$count]);
$Alpha=ord($output[$count+4156-3]);
if($Alpha >$byte)$byte=$byte|0x100;
$output[$count]=chr($byte-$Alpha);
}
echo hexdump($output);
//file_put_contents("gdHex.dump",hexdump($output));
//var_dump(1);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Fatal error: Uncaught Error: Call to undefined function imagecreate() in /in/9LbR8:87
Stack trace:
#0 {main}
thrown in /in/9LbR8 on line 87
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
69.71 ms | 401 KiB | 8 Q