原来的版本是用fopen打开文件的,如果要从ANDROID的APK中取文件,直接就洗白了
修改如下
void CCCrypto::MD5File(const char* path, unsigned char* output)
{
unsigned long len = 0;
//to make sure we can get data of files easily from ios,android,pc etc.
//we use CCFileUtils::sharedFileUtils()->getFileData
unsigned char* pData = CCFileUtils::sharedFileUtils()->getFileData(path, "r", &len);
if (pData == NULL || len == 0){
CCLOG("CCCrypto::MD5File() can‘t open file %s", path);
return;
}
MD5_CTX ctx;
MD5_Init(&ctx);
MD5_Update(&ctx, pData, len);
MD5_Final(output, &ctx);
//delete data as CCFileUtils::sharedFileUtils()->getFileData claimed.
if (pData != NULL)
delete[] pData;
}
quick-cocos2d-x 2.2.3 rc版本中 crypto.md5file() 的C++实现在ANDROID上有BUG,布布扣,bubuko.com
quick-cocos2d-x 2.2.3 rc版本中 crypto.md5file() 的C++实现在ANDROID上有BUG