/* Final wrapup - pad to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first)  */
void md5_finish(md5_state_t *ctx, guint8 digest[16])
/* Final wrapup - pad to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first)  */
void md5_finish(md5_state_t *ctx, guint8 digest[16])
{
    guint count;
    guint8 *p;
    count = (ctx->bits[0] >> 3) & 0x3F;
    p = (guint8 *) ctx->in + count;
    *p++ = 0x80;
    count = 64 - 1 - count;
    if (count < 8) {
        memset(p, 0, count);
        byteReverse(ctx->in, 16);
        MD5Transform(ctx->buf, ctx->in);
        memset(ctx->in, 0, 56);
    } else {
        memset(p, 0, count - 8);
    }
    byteReverse(ctx->in, 14);
    ctx->in[14] = ctx->bits[0];
    ctx->in[15] = ctx->bits[1];
    MD5Transform(ctx->buf, ctx->in);
    byteReverse(ctx->buf, 4);
    memcpy(digest, ctx->buf, 16);
    memset(ctx, 0, sizeof(md5_state_t));
}