I had figured this out .
first , upgrade php to 5.4.*
to use hex2bin and notice that hex2bin
input parameters doesn't have any spaces in it .
second , use xxd
with option -p
to get hex output with no offset and then remove spaces from piece of output .
that would work perfectly .