Embed MD5 digest in a directory path name
MD5 is simply a 128 bit number.

Convert the number into a string that is the ASCII representation of the number. Note: Usually this is done as hex number. If you make sure it is 0 padded it will be 32 characters long (as each 8 bits is converted into two hex digits). 

This is how I would do it:

static_assert(sizeof(int) == 4, "Figure it out with other sizes");

int*  data = reinterpret_cast&lt;int*&gt;(ret);
int   len  = 128 / (sizeof(int) * 8);

for(int i=len-1; i &gt;= 0; --i)
{
    std::cout &lt;&lt; std::setfill('0') &lt;&lt; std::setw(8) &lt;&lt; std::hex &lt;&lt; data[i];
}