使用xxtea加密或者解密文件
来源:互联网 发布:高达 知乎 编辑:程序博客网 时间:2024/06/05 02:29
预览
将 .lua
文件编译为 .luac
所涉及到的加密方法
环境配置
如果是cocos2d-x V3.3 或者更高级的版本, 你需要配置 cocos consol
(请查看 https://github.com/cocos2d/cocos2d-x/blob/v3/README.md)
如果版本是cocos2d-x V2.2.6, 你应该安装 Python
, 然后设置Python的环境变量.
使用方法
如果是cocos2d-x V3.3 或者更高级的版本, 在终端里输入 cocos luacompile [arguments]
如果版本是cocos2d-x V2.2.6, 在终端里,首先 cd
进目录tools/cocos2d-console/console
, 然后输入 ./cocos2d.py luacompile [arguments]
.
可用的参数(在终端里)
./projects/MyLuaGame/src
Specify source directory of lua files needed to be compiled,support mutiple source directoryyes-d, --dstdestination directory./projects/MyLuaGame/dst
Specify destination directory which bytecode files to be stored.yes-e, --encryptboolTrueWhether or not to encrypt lua files.no-k, --encryptkeyany stringMyLuaKey
Specify the encrypt key for encrypting lua scripts. It's only take effect when -e, --encrypt
is enabled. Default value is 2dxLua
.no-b, --encryptsignany stringMyLuaSign
Specify the encrypt sign for encrypting lua scripts. It's only take effect when --encrypt
is enabled. Default value is XXTEA
.no--disable-compileboolTrueWhether or not to compile lua scriptsno例子
使用luacompile时,有以下几种方式
src_dir
directory to bytecode files which luajit
supports, then store them in the dst_dir directory by the same directory structure.cocos luacompile -s src_dir -d dst_dir -e Truecocos2d-x V3.3 or higher versionPrecompile the Lua files in the src_dir
directory to bytecode files which luajit
supports, then encrypt this bytecoed files by xxtea
.The key
and sign
for encrypting are 2dxLua
and XXTEA
by default. By adding -k xxx -b xxx' to the command, developers can change the
keyand
sign,
-k xxxset the key value and
-b xxx` set the sign value. The encrypted files are stored in the dst_dir directory by the same directory structure.cocos luacompile -s src_dir -d dst_dir -e True --disable-compile Truecocos2d-x V3.3 or higher versionEncrypt the Lua files in the src_dir
by xxtea
, then store them in the dst_dir directory by the same directory structure. The key
and sign
for encrypting are 2dxLua
and XXTEA
by default. By adding -k xxx -b xxx' to the command, developers can change the
keyand
sign,
-k xxxset the key value and
-b xxx` set the sign value. This command is mainly used to make a set of encrypted files run both 32bit and 64bit iOS devices at the same time. Because Apple demand new app must support 64bit,but the stable luajit doesn't support the arm64bit, so providing this command to encrypt the lua files directly../cocos2d.py luacompile -hcocos2d-x V2.2.6Show the help message./cocos2d.py luacompile -s src_dir -d dst_dircocos2d-x V2.2.6Precompile the Lua files in the src_dir
directory to bytecode files which luajit
supports, then store them in the dst_dir directory by the same directory structure../cocos2d.py luacompile -s src_dir -d dst_dir -e Truecocos2d-x V2.2.6Precompile the Lua files in the src_dir
directory to bytecode files which luajit
supports, then encrypt this bytecoed files by xxtea
.TThe key
and sign
for encrypting are 2dxLua
and XXTEA
by default. By adding -k xxx -b xxx' to the command, developers can change the
keyand
sign,
-k xxxset the key value and
-b xxx` set the sign value. The encrypted files are stored in the dst_dir directory by the same directory structure../cocos2d.py luacompile -s src_dir -d dst_dir -e True --disable-compile Truecocos2d-x V2.2.6Encrypt the Lua files in the src_dir
by xxtea
, then store them in the dst_dir directory by the same directory structure. The key
and sign
for encrypting are 2dxLua
and XXTEA
by default, by adding -k xxx -b xxx' to the command, developers can change the
keyand
sign,
-k xxxset the key value and
-b xxx` set the sign value. This command is mainly used to make a set of encrypted files run both 32bit and 64bit iOS devices at the same time.注意: 如果在游戏里使用了xxtea加密,你必须调用在c++代码里,调用LuaStack里的setXXTEAKeyAndSign方法以设置key和sign来解密文件。
具体使用
加密lua为luac文件
cocos luacompile -s ${PWD}/src -d ${PWD}/src_et -e -k mXjv7U5dUl1aMTVV_xianlai -b SQLLiteData --disable-compile
解密:
LuaStack* stack = engine->getLuaStack();stack->setXXTEAKeyAndSign("mXjv7U5dUl1aMTVV_xianlai", strlen("mXjv7U5dUl1aMTVV_xianlai"), "SQLLiteData", strlen("SQLLiteData"));
0 0
- 使用xxtea加密或者解密文件
- xxtea 加密解密
- XXTea 加密/解密 字符串
- C++ XXTEA加密解密算法
- TEA、XTEA、XXTEA加密解密算法
- PHP加密解密函数之Xxtea
- C++ XXTEA分组加密解密算法
- cocos2dx使用xxtea加密资源
- cocos2dx使用xxtea加密资源
- xxtea luc加密后怎么和不加密的文件混合使用
- 基于xxtea算法文件加密工具
- 使用Base64加密解密文件
- PHP和Javascript的xxtea字符串加密/解密方法
- cocos2d-x 3.x学习笔记<三> 加密解密 xxtea
- cocos2dx lua XXTEA来加密解密实现详解
- XXTea加密 c++ 与 js 互相加解密
- 【数据加密】使用XXTEA对NSData进行加密
- xxtea官方解密
- ScrollView嵌套RecyclerView滑动冲突
- 学习hibernate的血泪史
- 影像组学下(Radiomic)的生存分析基本概念及统计分析
- Spring基础总结
- C++作业5
- 使用xxtea加密或者解密文件
- C++实验5—数组分离
- List 集合去除 null 元素
- Android 里面synchronized(this)的作用分析
- 最长上升子序列(LIS)
- 求凸包——Graham扫描算法
- ThinkPHP3.2结合jq实现图片的异步上传
- Oracle数据库表信息,序列,视图等导出,导入。(数据库备份和恢复)
- 调到应用商城评价