Logo Search packages:      
Sourcecode: gdcm version File versions

bool gdcm::Testing::ComputeMD5 ( const char *  buffer,
const unsigned long  buf_len,
char *  digest_str 
) [static]

MD5 stuff digest_str needs to be at least : strlen = [2*16+1]; string will be padded. (md5 are 32 bytes long)

Definition at line 71 of file gdcmTesting.cxx.

{
  if( !buffer || !buf_len )
    {
    return false;
    }
  md5_byte_t digest[16];
  md5_state_t state;
  md5_init(&state);
  md5_append(&state, (const md5_byte_t *)buffer, buf_len);
  md5_finish(&state, digest);

  //char digest_str[2*16+1];
  for (int di = 0; di < 16; ++di)
  {
    sprintf(digest_str+2*di, "%02x", digest[di]);
  }
  digest_str[2*16] = '\0';
  return true;
}


Generated by  Doxygen 1.6.0   Back to index