那位高人来给我讲解一下这段程序呀!yangyugw最好是你!(10分)

  • 主题发起人 主题发起人 cb1997
  • 开始时间 开始时间
C

cb1997

Unregistered / Unconfirmed
GUEST, unregistred user!
首先声明这段程序不是我的哈<br>是yangyugw的!<br>function uencrypt(str:string;len:integer):string;//解密函数<br>var sch:string;<br>j,i:integer;<br>newstr:string;<br>begin<br>sch:='x&amp;bsf0104MtTxR780926';<br>newstr:='';<br>j:=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; for i:=1 to len do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newstr:=newstr+chr(ord(str)-ord(sch[j]));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j:=j+1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if j&gt;20 then j:=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>result:=newstr;<br>end;<br><br>function encrypt(str:string;len:integer):string;//加密函数<br>var sch:string;<br>j,i:integer;<br>begin<br>sch:='x&amp;bsf0104MtTxR780926';<br>Randomize;<br>j:=1;<br>for i:=1 to 255 &nbsp;do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if i&lt;=len then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;str:=chr(ord(str)+ord(sch[j]))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;str:=str+chr(random(255)+ord(sch[j]));<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j:=j+1;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if j&gt;20 then j:=1;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>result:=str;<br>end;<br><br>程序主要是对字符串加密的!<br>那位能给我讲解一下
 
简单,<br>原理就是用另外一个字符代替原来的字符,<br>当然还可以在这个基础上把算法写的更复杂了。<br>
 
不外就是按一定规则将原字符变为加一字符,达到无法直接看到密码之类的功能.
 
哇,<br>10分太少了吧,<br>楼主,太看不起这个题了吧,<br><br>我来顶一下好了~~~~~~~~~~~呵可~~~~~~~~~~~~
 
yangyugw的这段程序写得挺不错的。<br>基本原理是将输入的字符串中的每一个字符(str)转换成<br>数字(ord(str))后,加上加密字符串中的一个字符(sch[j])<br>转换成的数字(ord(sch[j])),再将这两个数字之和转换成字<br>符赋给str,解密为反过程。<br>其中len为字符串有效长度。
 
后退
顶部