• 大小: 5KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-08
  • 语言: Python
  • 标签: lua  加密  cocos2dx  

资源简介

cocos2dx lua 加密工具,使用时将pyd拷贝到Python27\DLLs中,运行xxteaEncry.py 原理详见http://blog.csdn.net/cloud95/article/details/38110009

资源截图

代码片段和文件信息

import xxteaModule
import os

def ReadFile(filePath):
    file_object = open(filePath‘rb‘)
    all_the_text = file_object.read()
    file_object.close()
    return all_the_text

def WriteFile(filePathall_the_text):    
    file_object = open(filePath‘wb‘)    
    file_object.write(all_the_text)
    file_object.close()
    
def BakFile(filePathall_the_text):
    file_bak = filePath[:len(filePath)-3] + ‘bak‘   
    WriteFile(file_bakall_the_text)



def ListLua(path):
    fileList = [] 
    for rootdirsfiles in os.walk(path):
       for eachfiles in files:
           if eachfiles[-4:] == ‘.lua‘ :               
               fileList.append(root + ‘/‘ + eachfiles)
    return fileList

def EncodeWithXxteaModule(filePathkeysignment):    
    all_the_text = ReadFile(filePath)    

    if all_the_text[:len(signment)] == signment :
        return
    #bak lua
    BakFile(filePathall_the_text)
       
    encrypt = xxteaModule.encrypt(all_the_textkey)
    signment = signment + encrypt
    WriteFile(filePathsignment)    
    
def EncodeLua(projectPathkeysignment):
    path = projectPath + ‘/src‘
    fileList = ListLua(path)
    for files in fileList:
        EncodeWithXxteaModule(fileskeysignment)

def FixCpp(projectPathkeysignment):
    filePath = projectPath + ‘/frameworks/runtime-src/Classes/AppDelegate.cpp‘
    all_the_text = ReadFile(filePath)

    #bak cpp
    BakFile(filePathall_the_text)    


    pos = all_the_text.find(‘stack->setXXTEAKeyAndSign‘)
    left = all_the_text.find(‘(‘pos)
    right = all_the_text.find(‘;‘pos)   

    word = str.format(‘(“%s“ strlen(“%s“) “%s“ strlen(“%s“))‘ % (keykeysignmentsignment))
    
    all_the_text = all_the_text[:left] + word + all_the_text[right:-1]
    
    WriteFile(filePathall_the_text) 
    
    
    
projectPath = “D:/cocosIDEWork/aseGame/“
key = “123“
signment = “cloud“


EncodeLua(projectPathkeysignment)
FixCpp(projectPathkeysignment)
print “encode ok“





 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2047  2014-07-25 10:09  xxteaEncry.py
     文件        7680  2014-07-24 16:03  xxteaModule.pyd

评论

共有 条评论