source/Lib/CommonLib/MD5.h
void finalize(unsigned char digest[MD5_DIGEST_STRING_LENGTH])
  {
    unsigned count;
    unsigned char *p;

    /* Compute number of bytes mod 64 */
    count = (ctx.bits[0] >> 3) & 0x3F;

    /* Set the first char of padding to 0x80.  This is safe since there is
       always at least one byte free */
    p = ctx.in.b8 + count;
    *p++ = 0x80;

    /* Bytes of padding needed to make 64 bytes */
    count = 64 - 1 - count;

    /* Pad out to 56 mod 64 */
    if (count < 8) {
      /* Two lots of padding:  Pad the first block to 64 bytes */
      memset(p, 0, count);
      byteReverse(ctx.in.b32, 16);
      MD5Transform(ctx.buf, ctx.in.b32);

      /* Now fill the next block with 56 bytes */
      memset(ctx.in.b8, 0, 56);
    } else {
      /* Pad block to 56 bytes */
      memset(p, 0, count - 8);
    }
    byteReverse(ctx.in.b32, 14);

    /* Append length in bits and transform */
    ctx.in.b32[14] = ctx.bits[0];
    ctx.in.b32[15] = ctx.bits[1];

    MD5Transform(ctx.buf, ctx.in.b32);
    byteReverse((uint32_t *) ctx.buf, 4);
    memcpy(digest, ctx.buf, 16);

    memset(&ctx, 0, sizeof( ctx));    /* In case it's sensitive */
    /* The original version of this code omitted the asterisk. In
       effect, only the first part of ctx was wiped with zeros, not
       the whole thing. Bug found by Derek Jones. Original line: */
    // memset(ctx, 0, sizeof(ctx));    /* In case it's sensitive */
  }
/**
   * flush any outstanding MD5 data, write the digest into digest.
   */
flush any outstanding MD5 data, write the digest into digest.
flush any outstanding MD5 data write the digest into digest .
void finalize(unsigned char digest[MD5_DIGEST_STRING_LENGTH])
  {
    unsigned count;
    unsigned char *p;
    count = (ctx.bits[0] >> 3) & 0x3F;
    p = ctx.in.b8 + count;
    *p++ = 0x80;
    count = 64 - 1 - count;
    if (count < 8) {
      memset(p, 0, count);
      byteReverse(ctx.in.b32, 16);
      MD5Transform(ctx.buf, ctx.in.b32);
      memset(ctx.in.b8, 0, 56);
    } else {
      memset(p, 0, count - 8);
    }
    byteReverse(ctx.in.b32, 14);
    ctx.in.b32[14] = ctx.bits[0];
    ctx.in.b32[15] = ctx.bits[1];
    MD5Transform(ctx.buf, ctx.in.b32);
    byteReverse((uint32_t *) ctx.buf, 4);
    memcpy(digest, ctx.buf, 16);
    memset(&ctx, 0, sizeof( ctx));    
    // memset(ctx, 0, sizeof(ctx));    
  }
void finalize ( unsigned char digest [ MD5_DIGEST_STRING_LENGTH ] ) { unsigned count ; unsigned char * p ; count = ( ctx . bits [ 0 ] >> 3 ) & 0x3F ; p = ctx . in . b8 + count ; * p ++ = 0x80 ; count = 64 - 1 - count ; if ( count < 8 ) { memset ( p , 0 , count ) ; byteReverse ( ctx . in . b32 , 16 ) ; MD5Transform ( ctx . buf , ctx . in . b32 ) ; memset ( ctx . in . b8 , 0 , 56 ) ; } else { memset ( p , 0 , count - 8 ) ; } byteReverse ( ctx . in . b32 , 14 ) ; ctx . in . b32 [ 14 ] = ctx . bits [ 0 ] ; ctx . in . b32 [ 15 ] = ctx . bits [ 1 ] ; MD5Transform ( ctx . buf , ctx . in . b32 ) ; byteReverse ( ( uint32_t * ) ctx . buf , 4 ) ; memcpy ( digest , ctx . buf , 16 ) ; memset ( & ctx , 0 , sizeof ( ctx ) ) ; }
flush any outstanding MD5 data, write the digest into digest.
flush any outstanding MD5 data write the digest into digest .
/* Compute number of bytes mod 64 */ /* Set the first char of padding to 0x80.  This is safe since there is
       always at least one byte free */ /* Bytes of padding needed to make 64 bytes */ /* Pad out to 56 mod 64 */ /* Two lots of padding:  Pad the first block to 64 bytes */ /* Now fill the next block with 56 bytes */ /* Pad block to 56 bytes */ /* Append length in bits and transform */ /* In case it's sensitive */ /* The original version of this code omitted the asterisk. In
       effect, only the first part of ctx was wiped with zeros, not
       the whole thing. Bug found by Derek Jones. Original line: */ // memset(ctx, 0, sizeof(ctx));    /* In case it's sensitive */