Cocos LUA encryption and decryption obfuscation (version cocos3.4)

Source: Internet
Author: User


Cocos Luacompile
    • Cocos Luacompile
      • Overview
      • Usage
      • Available Arguments
      • Samples
Overview


Compile the.luafiles 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 is-e, --encryptenabled. 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 is--encryptenabled. 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 in*.luadirectory./projects/MyLuaGame/srcto*.luac. Then encrypt the Luac files with key are and sign areMyLuaKeyMyLuaSign.





We have some problems during the experiment, supporting 64-bit solutions:







out/-e-k testkey123456-b testSign123456--disable-compile





The whole process and test engineering are given below





1.0 Cocos Luacompile usage





I use the ordinary cocos2d lua, useless quick,quick seems to be able to the entire resources including images and audio are encrypted, packaged into a zip. But I didn't use quick. Look at the next Luacompile help, relatively simple AH.



Set up an Out folder at the root of the project, and then try it with this command:




Cocos luacompile-s src/out /


A lot of luac files are seen in the Out directory, which is smoother than expected. As the command says, the subdirectory is supported. Online said Luac will still be anti-compilation. It adds a key.




out/-e-k testkey123456-b testSign123456


He uses the Xxtea encryption algorithm, can see this article "Xxtea Reversible encryption and decryption algorithm C + + C # compatible version"



You also need to add setxxteakeyandsign to the Applicationdidfinishlaunching method of the AppDelegate.cpp file . This is the first pit where the Luacompile help did not mention it.






LuaStack* stack = engine->getLuaStack();
    stack->setXXTEAKeyAndSign("testKey123456", strlen("testKey123456"), "testSign123456", strlen("testSign123456"));

    if (engine->executeScriptFile("src/main.lua")) {
        return false;
2.64bit is not supported


The second pit is coming: Just beginning to run well in the Iphone4s simulator, iphone5s is dark. It turned out that Lua compiled, although faster, but not yet support 64-bit system, it is said Cocos2d end will give Luajit 64-bit solution, because Apple asked for AH.



and then because of the problem I got stuck for a while. Search on the Internet has no results, it is recommended to use quick. The game is finished, and it's a bit troublesome to turn quick.



suddenly notice the last option in Luacompile Help: –disable-compile, then change the command to the following:




out/-e-k testkey123456-b testSign123456--disable-compile



Also comes out luac files, but simply encrypts with Xxtea. This little game is completely enough.

Cocos LUA encryption and decryption obfuscation (version cocos3.4)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.