diff --git a/Assets/ManagedResources/~Lua/Base/HttpCrypt.lua b/Assets/ManagedResources/~Lua/Base/HttpCrypt.lua new file mode 100755 index 0000000000..f88ed43960 --- /dev/null +++ b/Assets/ManagedResources/~Lua/Base/HttpCrypt.lua @@ -0,0 +1,55 @@ +-- 对字符串进行加密解密 + +require "Common.BitMath" +function strSplit(input, delimiter) + input = tostring(input) + delimiter = tostring(delimiter) + if (delimiter=='') then return false end + local pos,arr = 0, {} + for st,sp in function() return string.find(input, delimiter, pos, true) end do + table.insert(arr, string.sub(input, pos, st - 1)) + pos = sp + 1 + end + table.insert(arr, string.sub(input, pos)) + return arr +end + +function StrToBytes(s) + local t={} + for i=1,string.len(s) do + table.insert(t,string.byte(string.sub(s,i,i))) + end + return t +end + +function HTTP_ENCRYPT(src, key) + local data = StrToBytes(src) + local keys = StrToBytes(key) + local sb = "" + for i = 1, #data do + local n = BitMath.andOp(255, data[i]) + BitMath.andOp(255, keys[(i - 1) % #keys + 1]) + sb = sb.."@"..n + end + return sb +end + +function HTTP_DECRYPT(src, key) + local list = strSplit(src, "@") + if not list or #list < 1 then + return src + end + table.remove(list, 1) + local keys = StrToBytes(key) + local data = "" + for i = 1, #list do + local n = list[i] - BitMath.andOp(255, keys[(i - 1) % #keys + 1]) + data = data .. string.char(n) + end + return data +end + + +-- local t = HTTP_ENCRYPT("fajkfkahsdfjkhkashd", "123") +-- print(t) +-- local data = HTTP_DECRYPT(t, "123") +-- print(data) \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Base/HttpCrypt.lua.meta b/Assets/ManagedResources/~Lua/Base/HttpCrypt.lua.meta new file mode 100644 index 0000000000..fa031a928d --- /dev/null +++ b/Assets/ManagedResources/~Lua/Base/HttpCrypt.lua.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c0a2e12bba84144f48f8b9b64c1e89c4 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua b/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua index 19eb9996d9..525613d459 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/BattleManager.lua @@ -1,4 +1,4 @@ -BattleManager = {} +BattleManager = {} local this = BattleManager local PassiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig) local SkillLogicConfig = ConfigManager.GetConfig(ConfigName.SkillLogicConfig) @@ -1014,7 +1014,7 @@ function this.RequestBattleDataByFightId(serverUrl, fightId, func) local uid = string.split(fightId, "_")[1] local requestUrl = string.format("http://%s/req/getFightRecord?uid=%s&fightid=%s", serverUrl, uid, fightId) LogGreen(requestUrl) - networkMgr:SendGetHttp(requestUrl, function(str) + LoginManager:SendGetHttp(requestUrl, function(str) --LogGreen(str) local json = require 'cjson' local data = json.decode(str) diff --git a/Assets/ManagedResources/~Lua/Modules/BindPhone/BindPhoneNumberManager.lua b/Assets/ManagedResources/~Lua/Modules/BindPhone/BindPhoneNumberManager.lua index 691aaec793..55a5516b9f 100644 --- a/Assets/ManagedResources/~Lua/Modules/BindPhone/BindPhoneNumberManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/BindPhone/BindPhoneNumberManager.lua @@ -61,7 +61,7 @@ function this.DOGetBindPhone(type, phoneNumber, code) local sign = Util.MD5Encrypt(string.format("%s%s%s%s%s%s", pid, gid, type, phoneNumber, time, signKey)) local code = code and code or "" - networkMgr:SendGetHttp(string.format("%s?pid=%s&gid=%s&token=%s&type=%s&phone=%s&code=%s&time=%s&sign=%s", + LoginManager:SendGetHttp(string.format("%s?pid=%s&gid=%s&token=%s&type=%s&phone=%s&code=%s&time=%s&sign=%s", GetBindUrl, pid, gid, token, type, phoneNumber, code, time, sign), this.OnCodeResult, nil, nil, nil) end diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua index 93d439872b..a543ea702d 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginManager.lua @@ -1,4 +1,4 @@ -LoginManager = {}; +LoginManager = {}; local this = LoginManager this.sign = "d13b3e8ef74bf72d8aafce3a1c8672a0" this.openId = nil @@ -124,7 +124,7 @@ function this.RequestRegist(name, pw, call) pw, this.sign)) RequestPanel.Show(Language[11132]) - networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/registerUser?userName=".. name .. "&password=".. pw .."&repeat=".. pw .. "&sign=" .. sign, + this:SendGetHttp(LoginRoot_Url .. "jl_loginserver/registerUser?userName=".. name .. "&password=".. pw .."&repeat=".. pw .. "&sign=" .. sign, function(str) RequestPanel.Hide() if str == nil then @@ -150,7 +150,7 @@ function this.RequestUser(name, pw, call) pw, this.sign)) RequestPanel.Show(Language[11134]) - networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/userLogin?userName=".. name .. "&password=".. pw .. "&sign=" .. sign, function(str) + this:SendGetHttp(LoginRoot_Url .. "jl_loginserver/userLogin?userName=".. name .. "&password=".. pw .. "&sign=" .. sign, function(str) RequestPanel.Hide() if str == nil then return @@ -179,6 +179,28 @@ function this.RequestUser(name, pw, call) end,nil,nil,nil) end +require("Base.HttpCrypt") +local CRYPT_KEY = "d53b3e8ef74bf72d8aafce3a1c8671a0" +function this:SendGetHttp(url, callback) + local request = url + LogGreen("Http请求:"..request) + if AppConst.Platform == "IOS" then + local urlList = string.split(url, "?") + urlList[2] = HTTP_ENCRYPT(urlList[2], CRYPT_KEY) + request = urlList[1] .. "?crypt=" .. urlList[2] + LogGreen("Http加密请求:"..request) + end + networkMgr:SendGetHttp(request, function(msg) + LogGreen("Http请求结果:"..msg) + if AppConst.Platform == "IOS" then + msg = HTTP_DECRYPT(msg, CRYPT_KEY) + LogGreen("Http请求结果解密:"..msg) + end + if callback then + callback(msg) + end + end, nil, nil, nil) +end return this \ No newline at end of file diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua index e0fab0095a..8d46ccf1e9 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua @@ -1,4 +1,4 @@ -require("Base/BasePanel") +require("Base/BasePanel") LoginPanel = Inherit(BasePanel) local this = LoginPanel @@ -281,7 +281,7 @@ function this.ShowNotice() if subNoticeID then LoginRoot_NoticeChannel = LoginRoot_NoticeChannel.. subNoticeID end - networkMgr:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign.."&packageName="..LoginRoot_NoticeChannel,function (str) + LoginManager:SendGetHttp(LoginRoot_Url .. "jl_loginserver/getNotice?timestamp="..timeStamp.."&sign=".. timeSign.."&packageName="..LoginRoot_NoticeChannel,function (str) UIManager.OpenPanel(UIName.NoticePopup,str) end, nil, nil, nil) end @@ -293,7 +293,7 @@ function this.RequestServerList(userId, callback) "%sjl_loginserver/getServerList?openId=%s&channel=%s&plat=android&sub_channel=%s&server_version=%s", LoginRoot_Url, userId, LoginRoot_Channel, LoginRoot_SubChannel, ServerVersion) Log(url) - networkMgr:SendGetHttp(url, callback, nil, nil, nil) + LoginManager:SendGetHttp(url, callback, nil, nil, nil) end @@ -646,7 +646,7 @@ function this.RequestHttpLogin() end Log(url) - networkMgr:SendGetHttp(url, this.OnReceiveLogin, nil, nil, nil) + LoginManager:SendGetHttp(url, this.OnReceiveLogin, nil, nil, nil) end --用户id登录