(Transfer) Let Quick-Cocos2D-X support encrypted PLIST files

First part: quick-cocos2d-x image resource encryption

In the previous part, we have implemented the encryption of image resources, but have not yet implemented plist Encryption of files. Although this encryption is not too important, it is not difficult to implement it. The following is a modification method.

The parsing of the plist file is in lib\cocos2d-x\cocos2dx In the CCSAXParser::parse(const char *pszFile) in \platform\CCSAXParser.cpp, we can see the following familiar statements:

char* pBuffer=(char*)CCFileUtils ::sharedFileUtils()->getFileData(pszFile, "rt",&size); 

With the foundation of the previous article, we only need to Change the sentence to the following:

char* pBuffer=( char*)CZHelperFunc::getFileData(pszFile, "rb",&size);< /span>

Note that the above parameters have changed, “rt” is changed to “rb”, because the encrypted file is no longer Plain text, so use the b parameter.

In addition, remember to include the header file HelperFunc.h, and include the statement Put it before the NS_CC_BEGIN statement in the CCSAXParser.cpp file, otherwise the compilation will fail.

The above modification is for Windows platform and Android platform, other platforms Please see the continuation for modification:

quick-cocos2d- xImage resource encryption (continued)

Original address: https://my.oschina.net/SunLight July/blog/184179

Leave a Comment

Your email address will not be published.