void MD5::final()
{
    if (finalized)
    {
	return;
    }

    unsigned char bits[8];
    unsigned int index, padLen;

    // Save number of bits
    encode(bits, count, 8);

    // Pad out to 56 mod 64.

    index = static_cast<unsigned int>((count[0] >> 3) & 0x3f);
    padLen = (index < 56) ? (56 - index) : (120 - index);
    update(PADDING, padLen);

    // Append length (before padding)
    update(bits, 8);
    // Store state in digest_val
    encode(digest_val, state, 16);

    // Zeroize sensitive information.
    memset(state, 0, sizeof(state));
    memset(count, 0, sizeof(count));
    memset(buffer, 0, sizeof(buffer));

    finalized = true;
}
void MD5::final()
{
    if (finalized)
    {
	return;
    }

    unsigned char bits[8];
    unsigned int index, padLen;

     
    encode(bits, count, 8);

     

    index = static_cast<unsigned int>((count[0] >> 3) & 0x3f);
    padLen = (index < 56) ? (56 - index) : (120 - index);
    update(PADDING, padLen);

     
    update(bits, 8);
     
    encode(digest_val, state, 16);

     
    memset(state, 0, sizeof(state));
    memset(count, 0, sizeof(count));
    memset(buffer, 0, sizeof(buffer));

    finalized = true;
}