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::CalcMD5File | (const char*,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
hzEcode hzMD5::CalcMD5File (const char* filepath)
{
// 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_ARGUMENT If the filepath is not supplied
// E_NOTFOUND If the filepath specified does not exist as a directory entry of any kind
// E_TYPE If the filepath names a directory entry that is not a file
// E_NODATA If the filepath is a file but empty
// E_OPENFAIL If the file specified could not be opened for reading
// E_OK If this MD5 value is calculated
_hzfunc("hzMD5::CalcMD5(file)") ;
ifstream is ; // Input stream
_md5_unit md5Unit ; // MD5 encoding unit
uchar* workBuf ; // Working data buffer
int32_t n ; // Buffer limit
hzEcode rc ; // Return code
rc = OpenInputStrm(is, filepath) ;
if (rc != E_OK)
return rc ;
n = 0;
workBuf = new uchar[8196];
for (;;)
{
is.read((char*) (workBuf + n), 4096);
if (!is.gcount())
break ;
n += is.gcount() ;
if (n & 0x3f)
continue ;
// s = _xlate_md5(workBuf, n, 0, md5Unit) ;
_xlate_md5(workBuf, n, 0,md5Unit) ;
n = 0;
}
// _xlate_md5(workBuf, n, m_md5val, md5Unit) ;
_xlate_md5(workBuf, n, (uchar*) m_Parts, md5Unit) ;
delete [] workBuf ;
is.close() ;
return E_OK ;
}