資源簡介
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
- 上一篇:Yolov3所需數據預處理python文件
- 下一篇:python python
評論
共有 條評論