位置: 编程技术 - 正文

cocos lua 加密与解密 混淆 (版本cocos3.4)(cocos creator 资源加密)

编辑:rootadmin
cocos luacompilecocos luacompileOverviewUsageAvailable ArgumentsSamplesOverview

推荐整理分享cocos lua 加密与解密 混淆 (版本cocos3.4)(cocos creator 资源加密),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:cocos luajit,cocoscreator图片加密,cocos2d加密,cocos creator 加密,cocoscreator图片加密,cocos lua教程,cocos creator 加密,cocos lua教程,内容如对您有帮助,希望把文章链接给更多的朋友!

Compile the .lua files to .luac.

Usage

cocos luacompile [arguments]

Available Argumentsargavailable valuesampledescriptionnecessary-h, --help--Show the help message and exitno-s, --srcsource directory./projects/MyLuaGame/srcSpecify source directory of lua files needed to be compiled.yes-d, --dstdestination directory./projects/MyLuaGame/srcSpecify destination directory bytecode files to be stored.yes-e, --encrypt--Enable the encrypting of lua files.no-k, --encryptkeyany stringMyLuaKeySpecify the encrypt key for the encrypting of lua scripts. It's only take effect when-e, --encrypt is enabled. Default value is2dxLua.no-b, --encryptsignany stringMyLuaSignSpecify the encrypt sign for the encrypting of lua scripts. It's only take effect when--encrypt is enabled. Default value isXXTEA.noSamplescocos luacompile -h. Show the help message.cocos luacompile -s ./projects/MyLuaGame/src -d ./projects/MyLuaGame/src -e -k MyLuaKey -b MyLuaSignCompile the *.lua in directory ./projects/MyLuaGame/src to*.luac. Then encrypt the luac files with key isMyLuaKey and sign isMyLuaSign.

我们在实验的过程中出现了一些问题,支持位的解决方案:

下面给出全过程与测试工程

1.0 cocos luacompile 用法

我用的普通的cocos2d lua,没用quick,quick好像可以对整个资源包括图像和音频都加密,打包成zip。但我没用quick.看了下luacompile 的 help,比较简单啊。

cocos lua 加密与解密 混淆 (版本cocos3.4)(cocos creator 资源加密)

先在项目根目录下建立了一个out的文件夹,然后就用这个命令试了下:

比预想的顺利,在out目录下看到了很多luac文件。正如命令里说的,支持子目录。网上说luac还是会被反编译。就加上了key。

他用的是XXTEA加密算法,可以看这篇文章 《XXTEA 可逆加密解密算法 C&#;&#; C#兼容版本》

还需要在AppDelegate.cpp文件的 applicationDidFinishLaunching方法中加入setXXTEAKeyAndSign。这点它那个luacompile 的help就没提了,这是第一个坑。

2.不支持bit

第二个坑马上来了:刚开始在IPhone4S模拟器运行好好的,IPhone5s就漆黑一片了。原来这样把lua编译后,虽然速度变快了,但还未支持位系统,据说cocos2d 年底会给出luajit 位解决方案,因为苹果要求的啊。

然后因为这个问题我卡了一会儿。网上搜了了也没什么结果,都推荐使用Quick。游戏都写完了,转Quick有点麻烦。

突然注意到luacompile help中最后一个选项:–disable-compile ,然后把命令改成下面这种:

也是出来luac文件,但只是简单用XXTEA加密。这样小游戏完全够用了。

查阅效果图:项目测试: /// decode: const char * key = "testKey"; int keylen = (int)strlen(key); const char * sign = "testSign"; int signlen = (int)strlen(sign); Data srcInfo = FileUtils::getInstance()->getDataFromFile("BugAnt.luac"); //decode: xxtea_long len = 0; unsigned char * result = xxtea_decrypt(srcInfo.getBytes() &#; signlen, (xxtea_long)srcInfo.getSize() - signlen, (unsigned char* )key, (xxtea_long)keylen, &len); printf("n result: %s n len; %ld",result,len);读取正常;

【Cocos2d-x】截图分享功能 Cocos2d-x截图实现atarget=_blankid=L1href=

cocos2dx 3.4 lua加密 setXXTEAKeyAndSign 1.在自己项目的根目录下按住Shift键,右击鼠标,点击在此处打开命令窗口然后输入cocosluacompile-ssrc/-dout/-e-ktestKey-btestSignment或者cocosluacompile-ssrc/-dout/-e-kte

Cocos2d-x V3.4 项目模板分析 0.分析之前首先新建一个project,项目会自动的使用cocos2dx的项目模板。在模板中有2个类:AppDelegate//Cocos2d应用程序代理类HelloWorld//Cocos2d示例类对应着有4

本文链接地址:https://www.jiuchutong.com/biancheng/368932.html 转载请保留说明!

上一篇:观察者模式——CCNotificationCenter(观察者模式指令)

下一篇:【Cocos2d-x】截图分享功能(cocos creator截图)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络