一个加密的问题,(100分)

  • 主题发起人 主题发起人 梦中过客
  • 开始时间 开始时间

梦中过客

Unregistered / Unconfirmed
GUEST, unregistred user!
谁能告诉我下面这些函数的意思,越详细越好,我很菜的,我给最高分200.<br>/字符串加密/还原(dir=0加密/1还原)<br>procedure EncryptP(var S:String; dir:byte);<br>const<br>&nbsp; mm=7;<br>&nbsp; key:array[0..mm] of bytxASe=($B2,$39,$AA,$55,$93,$6D,$84,$49);<br>var<br>&nbsp; i, L : DWord;<br>&nbsp; b, k : byte;<br>&nbsp; Rs:string;<br>begin<br>&nbsp; Rs := '';<br>&nbsp; L:=Length(S);<br>&nbsp; if L&lt;1 then exit;<br>&nbsp; k:=0;<br>&nbsp; if dir=0 then begin<br>&nbsp; &nbsp; //加密<br>&nbsp; &nbsp; for i := 1 to L do begin<br>&nbsp; &nbsp; &nbsp; b := byte(S) xor key[k];<br>&nbsp; &nbsp; &nbsp; Rs := Rs + IntToHex(b,2);<br>&nbsp; &nbsp; &nbsp; inc(k);<br>&nbsp; &nbsp; &nbsp; if k&gt;mm then k:=0;<br>&nbsp; &nbsp; end<br>&nbsp; end else if dir=1 then begin<br>&nbsp; &nbsp; //还原<br>&nbsp; &nbsp; i:=1;<br>&nbsp; &nbsp; while i&lt;L do begin<br>&nbsp; &nbsp; &nbsp; b:=HexCharToByte(S)*16+HexCharToByte(S[i+1]);<br>&nbsp; &nbsp; &nbsp; Rs := Rs + chr(b xor key[k]);<br>&nbsp; &nbsp; &nbsp; inc(i,2);<br>&nbsp; &nbsp; &nbsp; inc(k);<br>&nbsp; &nbsp; &nbsp; if k&gt;mm then k:=0;<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>&nbsp; S:=Rs;<br>end;<br>各位大大,这句key:array[0..mm] of bytxASe=($B2,$39,$AA,$55,$93,$6D,$84,$49);我也不懂,到底是一个什么样的常量,$B2什么的,我头都大了。<br><br>
 
十六进制的字符集吧
 
吐血推荐:下载110 http://www.down110.com
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部