高手们好!
我是个新手有个问题想请教各位!帮我看看这个“加密程序”吧?我怎么看都不明白为什么用它?用它的好处在那呀?请把程序的每一行给小弟注释上好吗拜托??????
程序如下:
unit crypt; interface
USES
Classes;
const
C1 = 52845;
C2 = 22719;
function Encrypt( S: String; Key: Word): String;
function Decrypt( S: String; Key: Word): String; implementation function Encrypt( S: String; Key: Word): String;
var
I: Integer;
j: Integer;
begin
Result := S; //为什么不明不白的用‘Result’??????
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
s:=Result;
Result:='';
for i:=1 to length(s) do
begin
j:=Integer(s[i]);
Result:=Result + Char(65+(j div 26))+Char(65+(j mod 26));
end;
end;function Decrypt( S: String; Key: Word): String;
var
I: Integer;
j: Integer;
begin
result:='';
for i:=1 to (length(s) div 2) do
begin
j:=(Integer(s[2*i-1])-65)*26;
j:=j+(Integer(s[2*i])-65);
result:=result + Char(j);
end;
s:=result;
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(S[I]) + Key) * C1 + C2;
end;
end;end.另外,Classes这个单元文件的作用到底是干什么的?为什么在uses要加它?程序中的‘Result’没有声明可以直接引用吗?
我是个新手有个问题想请教各位!帮我看看这个“加密程序”吧?我怎么看都不明白为什么用它?用它的好处在那呀?请把程序的每一行给小弟注释上好吗拜托??????
程序如下:
unit crypt; interface
USES
Classes;
const
C1 = 52845;
C2 = 22719;
function Encrypt( S: String; Key: Word): String;
function Decrypt( S: String; Key: Word): String; implementation function Encrypt( S: String; Key: Word): String;
var
I: Integer;
j: Integer;
begin
Result := S; //为什么不明不白的用‘Result’??????
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
s:=Result;
Result:='';
for i:=1 to length(s) do
begin
j:=Integer(s[i]);
Result:=Result + Char(65+(j div 26))+Char(65+(j mod 26));
end;
end;function Decrypt( S: String; Key: Word): String;
var
I: Integer;
j: Integer;
begin
result:='';
for i:=1 to (length(s) div 2) do
begin
j:=(Integer(s[2*i-1])-65)*26;
j:=j+(Integer(s[2*i])-65);
result:=result + Char(j);
end;
s:=result;
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(S[I]) + Key) * C1 + C2;
end;
end;end.另外,Classes这个单元文件的作用到底是干什么的?为什么在uses要加它?程序中的‘Result’没有声明可以直接引用吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货