cocos2dx 3.4 lua加密 和 解密

1.在自己项目的根目录下按住Shift键,


右击鼠标,


点击“在此处打开命令窗口”


然后输入


cocos luacompile -s src/ -d out/ -e -k testKey -b testSignment

或者


cocos luacompile -s src/ -d out/ -e -k testKey -b testSignment --disable-compile


运行可以生成一个out文件夹,//(后者是保证在苹果64位上兼容,生成的文件夹为isable-compile),



里面就是你需要的加密后的lua文件;


2.在这个位置加入对应的东西即可。

查看图片


/// decode:
    const char * key = "testKey";
    int keylen = (int)strlen(key);
    const char * sign = "testSignment";
    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);

展开阅读全文

没有更多推荐了,返回首页