|
楼主 |
发表于 2009-4-30 16:43:19
|
显示全部楼层
先说Data存哪些资料
Data[0] = 0 +玩家名称(10进位)
Data[1] = 1 +英雄类型
Data[2] = 2 +英雄经验值
Data[3] = 3 +英雄力量差距
Data[4] = 4 +英雄敏捷差距
Data[5] = 5 +英雄智慧差距
Data[6] = 6 +英雄物品1
Data[7] = 7 +英雄物品2
Data[8] = 8 +英雄物品3
Data[9] = 9 +英雄物品4
Data[10] = 10 +英雄物品5
Data[11] = 11 +英雄物品6
Data[12] = 12 +英雄血量%
Data[13] = 13 +英雄魔力%
Data[14] = 14 +英雄X座标
Data[15] = 15 +英雄Y座标
Data[16] = 16 +玩家黄金
Data[17] = 17 +玩家原木
Data[18] =随机种子
Data[19] =认证码( 2^31 * Data[1] * Data[2] * ..... * Data[18] + Data[0] )
每次加密前都会先创造交换用的全字串以下是示意代码- function I102S64 takes integer i returns string
- // ......
- // 10进位转64进位
- // ......
- endfunction
复制代码- function CreateTempPassword takes nothing returns nothing
- local integer i = 0
- local integer i2
- local integer TempInteger
- local string TempString
- local string TempString1
- local string TempString2
- local string NewString
- local string StringAll = "0123456789" + "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- local integer StringAllLength = GetStringLength(StringAll)
- local string StringIndex = GetPlayerName(GetTriggerPlayer) + I102S64(Data[19]) + "AnyString"
- local integer array Index
- // StringIndex补足字数
- loop
- exitwhen StringLength(StringIndex) >= StringAllLength
- set StringIndex = StringIndex + StringIndex
- endloop
- //将StringIndex每个字都换为10进位不合法字元则为最大值一半
- loop
- set TempString = SubString(StringIndex,i,i+1)
- set i = i + 1
- set i2 = 0
- loop
- exitwhen TempString == SubString(StringAll,i2,i2+1) or i2 > StringAllLength
- set i2 = i2 + 1
- endloop
- if i2 > StringAllLength then
- set Index[i] = StringAllLength / 2
- else
- set Index[i] = i2 + 1
- endif
- exitwhen i == StringAllLength
- endloop
- //创造新全字串这部份文字不好说明..自己看吧
- set TempString = ""
- set i2 = 0
- loop
- set ts = SubString(StringAll,i2,i2+1)
- set TempInteger = 0
- loop
- exitwhen TempString == SubString(StringAll,TempInteger,TempInteger+1)
- set TempInteger = TempInteger + 1
- endloop
- set i2 = i2 + 1
- if ti < Index[i2] then
- set TempInteger = 1
- elseif ti > Index[i2] then
- set TempInteger = -1
- else
- set TempInteger = 0
- endif
- //每执行两次就会反转
- if i2-i2/2/2 == 0 then
- set TempInteger = -TempInteger
- endif
- set ts1 = SubString(NewString,0,i2/2+ti)
- set ts2 = SubString(NewString,i2/2+ti,i2)
- set NewString = ts1 + ts + ts2
- exitwhen i2 == StringAllLength
- endloop
- // NewString就会是新排列过的StringAll
- // Ex:根据Data[19]的不同0123456789可能为0246798531也可能为1237986540或是其他组合
- endfunction
复制代码 接下来是加密部分这就比较简单了
简单来说就是对应位置换上新的字串
EX:
原字串0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
新字串lSo3nQeBgR6JmpIYHdPA15fqkaKcTXzCGr8syVhU2O7LxtEjwbMuF0WNivZ94D
密码如果为A1Bg7Tr
就会转变为sSyHBNT
示意代码- function PasswordAddPassword takes nothing returns nothing
- local integer i1 = 0
- local integer i2
- local string EnterString //要转换的字串
- local string StringAll1 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- local string StringAll2 = "lSo3nQeBgR6JmpIYHdPA15fqkaKcTXzCGr8syVhU2O7LxtEjwbMuF0WNivZ94D"
- local string NewString = ""
- local string TempString
- local integer exit = StringLength(EnterString)
- loop
- exitwhen i1 > exit
- set TempString = SubString(EnterString,i1,i1+1)
- set i2 = 0
- loop
- exitwhen TempString == SubString(StringAll1,i2,i2+1) or i2 > StringAllLength
- set i2 = i2 + 1
- endloop
- if i2 > StringAllLength then
- set NewString = NewString + TempString
- else
- set NewString = NewString + SubString(StringAll2,i2,i2+1)
- endif
- set i1 = i1 + 1
- endloop
- // NewString变为被加密过的密码
- //不能加密的字串保留原字
- endfunction
复制代码 地图中的加密就是
loop
CreateTempPassword
PasswordAddPassword
endloop
做成多次加密
读取密码的时候反加密密码(一般改过密码就会出现差异巨大的数值)
再比对Data[0] (玩家名称索引)
还有比对Data[19] (认证码)瞎猜是不太可能相同的机率比中奖券还低..
最后还有隐藏式密码请参考本地图
还需要补充欢迎提出 |
|