<p>Using the PHP <a href="http://www.php.net/pack" rel="noreferrer">pack()</a> function, I have converted a string into a binary hex representation:</p>

<pre><code>$string = md5(time); // 32 character length
$packed = pack('H*', $string);
</code></pre>

<p>The H* formatting means "Hex string, high nibble first".</p>

<p>To unpack this in PHP, I would simply use the <a href="http://www.php.net/unpack" rel="noreferrer">unpack()</a> function with the H* format flag.</p>

<p>How would I unpack this data in Python?</p>

In Python you use the
struct
module for this.
```
```
>>> from struct import *
>>> pack('hhl', 1, 2, 3)
'\x00\x01\x00\x02\x00\x00\x00\x03'
>>> unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03')
(1, 2, 3)
>>> calcsize('hhl')
8
```
```
HTH