cocos lua 加密与解密 混淆 (版本号cocos3.4)
cocos luacompile
Overview
Compile the .lua
files to .luac
.
Usage
cocos luacompile [arguments]
Available Arguments
arg | available value | sample | description | necessary |
---|---|---|---|---|
-h, --help | - | - | Show the help message and exit | no |
-s, --src | source directory | ./projects/MyLuaGame/src |
Specify source directory of lua files needed to be compiled. | yes |
-d, --dst | destination directory | ./projects/MyLuaGame/src |
Specify destination directory bytecode files to be stored. | yes |
-e, --encrypt | - | - | Enable the encrypting of lua files. | no |
-k, --encryptkey | any string | MyLuaKey |
Specify the encrypt key for the encrypting of lua scripts. It's only take effect when-e, --encrypt is enabled. Default value is2dxLua . |
no |
-b, --encryptsign | any string | MyLuaSign |
Specify the encrypt sign for the encrypting of lua scripts. It's only take effect when--encrypt is enabled. Default value isXXTEA . |
no |
Samples
cocos luacompile -h
. Show the help message.cocos luacompile -s ./projects/MyLuaGame/src -d ./projects/MyLuaGame/src -e -k MyLuaKey -b MyLuaSign
Compile the*.lua
in directory./projects/MyLuaGame/src
to*.luac
. Then encrypt the luac files with key isMyLuaKey
and sign isMyLuaSign
.
我们在实验的过程中出现了一些问题,支持64位的解决方式:
cocos luacompile -s src/ -d out/ -e -k testKey123456 -b testSign123456 --disable-compile
以下给出全过程与測试project
1.0 cocos luacompile 使用方法
我用的普通的cocos2d lua,没用quick,quick好像能够对整个资源包含图像和音频都加密。打包成zip。但我没用quick.看了下luacompile 的 help,比較简单啊。
先在项目根文件夹下建立了一个out的文件夹,然后就用这个命令试了下:
cocos luacompile -s src/ -d out/
比预想的顺利。在out文件夹下看到了非常多luac文件。
正如命令里说的,支持子文件夹。网上说luac还是会被反编译。就加上了key。
cocos luacompile -s src/ -d out/ -e -k testKey123456 -b testSign123456
他用的是XXTEA加密算法,能够看这篇文章 《XXTEA 可逆加密解密算法 C++ C#兼容版本号》
还须要在AppDelegate.cpp文件的 applicationDidFinishLaunching方法中增加setXXTEAKeyAndSign。这点它那个luacompile 的help就没提了,这是第一个坑。
LuaStack* stack = engine->getLuaStack();
stack->setXXTEAKeyAndSign("testKey123456", strlen("testKey123456"), "testSign123456", strlen("testSign123456")); if (engine->executeScriptFile("src/main.lua")) {
return false;
2.不支持64bit
第二个坑立即来了:刚開始在IPhone4S模拟器执行好好的。IPhone5s就漆黑一片了。原来这样把lua编译后。尽管速度变快了,但还未支持64位系统,据说cocos2d 年底会给出luajit 64位解决方式,由于苹果要求的啊。
然后由于这个问题我卡了一会儿。网上搜了了也没什么结果。都推荐使用Quick。游戏都写完了。转Quick有点麻烦。
突然注意到luacompile help中最后一个选项:–disable-compile ,然后把命令改成以下这样的:
cocos luacompile -s src/ -d out/ -e -k testKey123456 -b testSign123456 --disable-compile
也是出来luac文件,但仅仅是简单用XXTEA加密。这样小游戏全然够用了。
查阅效果图:
项目測试:
/// decode:
const char * key = "testKey123456";
int keylen = (int)strlen(key);
const char * sign = "testSign123456";
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);
读取正常;
cocos lua 加密与解密 混淆 (版本号cocos3.4)的更多相关文章
- cocos lua 加密方案
cocos2d使用的是luajit,lua原生编译出来的bytecode和luajit是不兼容的,所以直接用luac法编译出来的bytecode脚本无法在cocos2d中使用. 目前所指的解决方案有2 ...
- base64随机字符混淆加密、解密-美拍视频地址解密,反推加密算法
用火车头测试采集美拍的数据时无意中发现美拍的视频地址是一段加了混淆字符串的base64代码.如下图 于是好奇之下研究了下解密算法.具体过程省略800字.发现美拍的视频解密是通过js完成,于是找到了具体 ...
- php+js的 authcode 混淆加密和解密,php和js可以通用加密和解密
<script> //md5.js var hexcase = 0; function hex_md5(a) { return rstr2hex(rstr_md5(str2rstr_utf ...
- RSA加密、解密、签名、验签的原理及方法
一.RSA加密简介 RSA加密是一种非对称加密.可以在不直接传递密钥的情况下,完成解密.这能够确保信息的安全性,避免了直接传递密钥所造成的被破解的风险.是由一对密钥来进行加解密的过程,分别称为公钥和私 ...
- 常见的加密和解密算法—DES
一.DES加密概述 DES全称为Data Encryption Standard,即数据加密标准,是一种使用密钥加密的块算法,1977年被美国联邦政府的国家标准局确定为联邦资料处理标准(FIPS),并 ...
- Spring对外部属性文件指定的某个属性进行加密、解密
[From] http://blog.csdn.net/ethanq/article/details/7333897 在我们开发当中,经常会用到spring框架来读取属性文件的属性值,然后使用占位符引 ...
- ASP.NET数据库连接字符串的加密与解密
ASP.NET web.config中,数据库连接字符串的加密与解密. 虽然不怎么新鲜,但相信还是有许多人不知道,好,不说废话,直接给方法:开始--->运行,输入cmd,接着输入以下内容 加密: ...
- Cocos2d-x--iOS平台lua加密成luac资源方法和Jsc文件<MAC平台开发试用--windows平台暂未研究>
首先要说.近期真的是太忙了.好久没写博客了,今天正好有空,就写一下近期在写游戏中的一些发现: 话说,基于Cocos2dx 引擎 + 脚本写游戏,至今的感触就是能够进行增量更新和即时编译 ...
- .net中加密与解密
.Net中的加密解密 引言 在一些比较重要的应用场景中,通过网络传递数据需要进行加密以保证安全.本文将简单地介绍了加密解密的一些概念,以及相关的数字签名.证书,最后介绍了如何在.NET中对数据进行对称 ...
随机推荐
- python开发_tkinter_单选按钮
这篇blog主要是描述python中tkinter的单选按钮操作 下面是我做的demo 运行效果: ====================================== 代码部分: ===== ...
- 如何设置VMware中Linux命令行环境全屏
在VMware安装Linux后默认屏幕为640×480,如需修改,则请参考以下步骤.以下以CentOS 6.6安装于VMware Workstation 9中为例说明. 1.默认640x480x16, ...
- ROWID面试题-删除表中重复数据(重复数据保留一个)
/* ROWID是行ID,通过它一定可以定位到r任意一行的数据记录 ROWID DNAME DEPTNO LOC ------------------ ------------------------ ...
- cocos2dx 3.0 中文 iconv 转换函数
//#include <string> #pragma once #include "cocos2d.h"; #include "iconv\include\ ...
- cocos2d-x项目101次相遇:使用触摸事件移动 精灵
cocos2d-x 101次相遇 / 文件夹 1 安装和环境搭建 -xcode 2 Scenes , Director, Layers, Sprites 3 建立图片菜单 4 在 ...
- Reverse Engineering the NC ECU (revisited) -- SH7508
http://forum.miata.net/vb/showthread.php?t=536601 Hey all! About 5 years ago, there was a great thre ...
- 运用Android ROM Manager应用安装ClockworkMod Recovery的详细教程
在安装ClockworkMod Recovery恢复模式之前,建议先认识下Google Android平台的ClockworkMod Recovery恢复模式 对于Android ROM Manage ...
- My simplified pickit2 clone
http://simon.derr.free.fr/site/spip/spip.php?article11 This is a description of my very simplified h ...
- C语言 const, static, static const 的区别
基本定义: const 就是只读的意思,只在声明中使用;static 一般有2个作用,规定作用域和存储方式. 对于局部变量, static规定其为静态存储方式, 每次调用的初始值为上一次调用的值,调 ...
- VC6 下 libpng 库的编译与初步使用
VC6 下 libpng 库的编译与初步使用 目录 libong 库的介绍 VC6 下 libpng 的编译 下载 libpng 与 zlib 进行编译 得到 .lib 文件 初步使用 对 VC6 ...