There is a small code:

function raw2hex($raw) { $m = unpack('H*', $raw); return $m[1]; } function hex2raw($hex) { return pack('H*', $hex); } $bin = hex2raw(0x32 . 0x2B . 0x32);//2+2 $hex = raw2hex($bin); print $hex; 

Returns a string of random codes (504350).
And I need to get hex codes (0x32,0x2B, 0x32).
I've been fighting for several hours already.

    1 answer 1

     function hex($s) { $v = unpack('H*', $s); return chunk_split($v[1], 2, ' '); } function unhex($s) { return pack('H*', str_replace(' ', '', $s)); }