Please note the following legal notice. This function is derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm Calculate the MD5 digest for the supplied file
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzMD5::CalcMD5 | (hzChain&,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
hzEcode hzMD5::CalcMD5 (hzChain& Z)
{
// Category: Codec
//
// Please note the following legal notice. This function is derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm
//
// Calculate the MD5 digest for the supplied file
//
// Arguments: 1) filepath The file to be hashed
//
// Returns: E_NODATA If the input chain is empty
// E_OK If this MD5 value is calculated
_hzfunc("hzMD5::CalcMD5(hzChain)") ;
_md5_unit md5Unit ; // MD5 encoding unit
chIter zi ; // Input chain iterator
uchar* buf ; // Working data buffer
uint32_t nBytes ; // No of bytes extracted from input chain
if (!this)
hzexit(E_CORRUPT, "No instance") ;
if (!Z.Size())
return E_NODATA ;
zi = Z ;
// s = nil ;
nBytes = 0;
buf = new uchar[8196];
for (;;)
{
nBytes = zi.Write(buf, 4096);
if (!nBytes)
break ;
zi += nBytes ;
_xlate_md5(buf, nBytes, 0,md5Unit) ;
}
_xlate_md5(buf, nBytes, (uchar*) m_Parts, md5Unit) ;
delete [] buf ;
return E_OK ;
}