cocos2d-x 文件MD5校验(12)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-15 19:49 点击:次
p> memcpy( &m_lpszBuffer[nIndex], Input, nPartLen );
p> Transform( m_lpszBuffer );
p> for (i = nPartLen; i + 63 < nInputLen; i += 64)
p> {
p> Transform( &Input[i] );
p> }
p> nIndex = 0;
p> }
p> else
p> {
p> i = 0;
p> }
p>
p> // Buffer remaining input
p> memcpy( &m_lpszBuffer[nIndex], &Input[i], nInputLen-i);
p>}
p>
p>
p>
p>std::string CMD5Checksum::GetMD5OfString(std::string strString)
p>{
p> CMD5Checksum MD5Checksum; //checksum object
p> int nLength = strString.length(); //number of bytes read from the file
p> //const int nBufferSize = 1024; //checksum the file in blocks of 1024 bytes
p> BYTE *Buffer; //buffer for data read from the file
p> Buffer=(BYTE*)(strString.c_str());
p> //checksum the file in blocks of 1024 bytes
p> //while ((nLength = File.Read( Buffer, nBufferSize )) > 0 )
p> //{
p> MD5Checksum.Update( Buffer, nLength );
p> //}
p> //finalise the checksum and return it
p> return MD5Checksum.Final();
p>}
p>
p>使用方法
p>[cpp]
p>std::string pszPath = CCFileUtils::sharedFileUtils()->getWritablePath()+"data.zip";
p> std::string strFileMD5 = CMD5Checksum::GetMD5(pszPath);
p>
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>