http://cn.cocos2d-x.org/tutorial/show?id=1507
http://cn.cocos2d-x.org/tutorial/show?id=1447
http://blog.sina.com.cn/s/blog_71ad028b0101ms4n.html
http://cn.cocos2d-x.org/tutorial/show?id=1447
代码加密,
1.到quick建立的工程目录下右键在此打开cmd命令:输入下面代码 加密src文件夹
D:\quick-cocos2d-x-3.3rc1\quick\bin\compile_scripts.bat -i src -o res/game.zip -e xxtea_zip -ek MYKEY -es XT
2.然后在D:\codeide\test\frameworks\runtime-src\Classes\AppDelegate.cpp里加入:
//compile_scripts.bat -i src -o res/game.zip -e xxtea_zip -ek MYKEY -es XT
//pStack->setXXTEAKeyAndSign("abcd", 4, "SIGNCODE", 8);
stack->setXXTEAKeyAndSign("MYKEY", 5, "XT", 2);
stack->loadChunksFromZIP("res/game.zip");
stack->executeString("require 'main'");
3.最后编译发布程序的时候要记得把源代码文件夹从项目中移除或者改名为src1
到工程目录下D:\codeide\test\frameworks\runtime-src\proj.android
运行build_apk.bat生成apk文件,
右键解压缩此apk文件,assets下没有src源代码文件了,如果不进行此过程直接运行build_apk.bat的话会有src文件,
这样的话,手机上安装后,然后用360手机助手电脑版导出此应用就可以得到此apk文件,右键解压后src代码文件原封不动的出现,太可怕了。
资源加密
D:\quick-cocos2d-x-3.3\quick\bin\pack_files -i res -o resnew -es XXTEA -ek pa
http://www.cocoachina.com/bbs/read.php?tid-278418-page-1.html
http://my.oschina.net/SunLightJuly/blog/184061
是将res中的资源文件进行加密,加密后的文件存放到resnew文件夹中
最新实践:
代码加密
D:\quick-cocos2d-x-3.3\quick\bin\compile_scripts.bat -i src -o src.zip -e xxtea_zip -ek dishukey -es pa
资源加密
D:\quick-cocos2d-x-3.3\quick\bin\pack_files.bat -i res -o res.zip -m zip -ek XXTEA -es pa
D:\quick-cocos2d-x-3.3\quick\bin\pack_files.bat -i res -o resnew -ek dishukey -es pa
D:\quick-cocos2d-x-3.3\quick\bin\pack_files.bat -i res -o resnew -x fonts -ek dishukey -es pa
资源加密只加密image文件夹,只加密图片,plist和字体fnt和音乐不要加密
src和 res文件夹都打包成zip后,修改AppDelegate.cpp,运行build_native.bat,到eclipse-adt里的assets文件夹下把src和res都删除,
黏贴进去src.zip和res.zip
点击运行发布apk
代码加密和资源加密要用同样的key和sign
AppDelegate.cpp要改下:
stack->setXXTEAKeyAndSign("dishukey", 8, "pa", 2);
stack->loadChunksFromZIP("src.zip");
stack->executeString("require 'main'");
CCImage.cpp的initWithImageFile 和 initWithImageFileThreadSafe改一下,#include "HelperFunc.h"
//jiami ziyuan
//Data data = FileUtils::getInstance()->getDataFromFile(_filePath);
Data data = HelperFunc::getData(_filePath)
用vs打开cocos工程验证下有没有错。
Android.mk也改一下
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/. \
$(LOCAL_PATH)/.. \
$(LOCAL_PATH)/platform \
$(LOCAL_PATH)/base \
$(LOCAL_PATH)/../external \
$(LOCAL_PATH)/../external/tinyxml2 \
$(LOCAL_PATH)/../external/unzip \
$(LOCAL_PATH)/../external/chipmunk/include/chipmunk \
$(LOCAL_PATH)/../external/xxhash \
$(LOCAL_PATH)/../external/nslog \
$(LOCAL_PATH)/../../runtime-src/Classes/quick-src/extra/apptools
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/. \
$(LOCAL_PATH)/platform \
$(LOCAL_PATH)/../external \
$(LOCAL_PATH)/../external/tinyxml2 \
$(LOCAL_PATH)/../external/unzip \
$(LOCAL_PATH)/../external/chipmunk/include/chipmunk \
$(LOCAL_PATH)/../external/edtaa3func \
$(LOCAL_PATH)/../external/xxhash \
$(LOCAL_PATH)/../external/ConvertUTF \
$(LOCAL_PATH)/../external/nslog \
$(LOCAL_PATH)/../../runtime-src/Classes/quick-src/extra/apptools
TexturePacker图片加密:
http://www.it165.net/pro/html/201305/5703.html