public function hex2bin($hexString)
    {
        $pos = 0;
        $result = '';
        while ($pos < strlen($hexString)) {
            if (strpos(" \t\n\r", $hexString[$pos]) !== false) {
                ++$pos;
            } else {
                $code = hexdec(substr($hexString, $pos, 2));
                $pos += 2;
                $result .= chr($code);
            }
        }

        return $result;
    }