C
crystal_fly
Unregistered / Unconfirmed
GUEST, unregistred user!
我的加密是这样的 但是写的解密却总是出错 到底该怎么写呢~~帮帮忙~~谢谢
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,n,k,l: Integer;
s: String;
begin
//加密算法实现
n:=length(Form2.password);
if (n>length(memo1.Text)) then
l:=0
else
l:=1;
t:=memo1.Text;
memo2.Clear;
case l of
0:
begin
for k:=1 to Length(memo1.Text)do
begin
s:=memo1.Lines.Strings[0];
if (ord(s[k])<>13) and (ord(s[k])<>10) and (ord(s[k])<>32) then
s[k]:=chr(ord(s[k]) xor ord(Form2.password[k]));
end;
memo2.Lines.Add(s);
end;
1:
for i:=0 to memo1.Lines.Count-1do
begin
s:=memo1.Lines.Strings;
for j:=1 to length(s)do
begin
if (ord(s[j])<>13) and (ord(s[j])<>10) and (ord(s[j])<>32) then
begin
if (j<=n) then
s[j]:=chr(ord(s[j]) xor ord(Form2.password[j]))
else
s[j]:=chr(ord(s[j]) xor ord(Form2.password[j mod n]));
end;
end;
memo2.Lines.Add(s);
end;
end;
memo1.Clear;
memo3.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,n,k,l: Integer;
s: String;
begin
//加密算法实现
n:=length(Form2.password);
if (n>length(memo1.Text)) then
l:=0
else
l:=1;
t:=memo1.Text;
memo2.Clear;
case l of
0:
begin
for k:=1 to Length(memo1.Text)do
begin
s:=memo1.Lines.Strings[0];
if (ord(s[k])<>13) and (ord(s[k])<>10) and (ord(s[k])<>32) then
s[k]:=chr(ord(s[k]) xor ord(Form2.password[k]));
end;
memo2.Lines.Add(s);
end;
1:
for i:=0 to memo1.Lines.Count-1do
begin
s:=memo1.Lines.Strings;
for j:=1 to length(s)do
begin
if (ord(s[j])<>13) and (ord(s[j])<>10) and (ord(s[j])<>32) then
begin
if (j<=n) then
s[j]:=chr(ord(s[j]) xor ord(Form2.password[j]))
else
s[j]:=chr(ord(s[j]) xor ord(Form2.password[j mod n]));
end;
end;
memo2.Lines.Add(s);
end;
end;
memo1.Clear;
memo3.Clear;
end;