标签:style blog class code java javascript color get string set rgb
先加密游戏资源然后
改cocos2dx底层代码,在读取的时候进行解密
1 unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) 2 { 3 unsigned char * pBuffer = NULL; 4 CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters."); 5 *pSize = 0; 6 do 7 { 8 // read the file from hardware 9 std::string fullPath = fullPathForFilename(pszFileName); 10 FILE *fp = fopen(fullPath.c_str(), pszMode); 11 CC_BREAK_IF(!fp); 12 13 fseek(fp,0,SEEK_END); 14 *pSize = ftell(fp); 15 fseek(fp,0,SEEK_SET); 16 pBuffer = new unsigned char[*pSize]; 17 *pSize = fread(pBuffer,sizeof(unsigned char), *pSize,fp); 18 19 decode(pBuffer, *pSize); //在此调用解密函数 20 fclose(fp); 21 } while (0); 22 23 if (! pBuffer) 24 { 25 std::string msg = "Get data from file("; 26 msg.append(pszFileName).append(") failed!"); 27 28 CCLOG("%s", msg.c_str()); 29 } 30 return pBuffer; 31 }
cocos2dx加密解密资源,码迷,mamicode.com
标签:style blog class code java javascript color get string set rgb
原文地址:http://www.cnblogs.com/kgdnone/p/3700774.html