function Encrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
{自己加步骤}
end;function Decrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
{自己加步骤}
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
const
cKey1 = '谁想试试怎么破';
cKey2 = '我可不愿意这样玩(1)我可不愿意这样玩(2)我可不愿意这样玩(3)';
cKey3 = 'Memo2.Text := Decrypt(Encrypt(Memo1.Text, cKey), cKey);';
var
S: string; //加密后的字符
begin
S := Encrypt(Encrypt(Encrypt(Memo1.Text, cKey1), cKey2), cKey3);
ShowMessage(S);
Memo2.Text := Decrypt(Decrypt(Decrypt(S, cKey3), cKey2), cKey1);
end;
var
I, J: Integer;
begin
J := 1;
Result := '';
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
{自己加步骤}
end;function Decrypt(mStr: string; mKey: string): string;
var
I, J: Integer;
begin
J := 1;
Result := '';
{自己加步骤}
for I := 1 to Length(mStr) do begin
Result := Result + Char(Ord(mStr[I]) xor Ord(mKey[J]));
if J + 1 <= Length(mKey) then
Inc(J)
else J := 1;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
const
cKey1 = '谁想试试怎么破';
cKey2 = '我可不愿意这样玩(1)我可不愿意这样玩(2)我可不愿意这样玩(3)';
cKey3 = 'Memo2.Text := Decrypt(Encrypt(Memo1.Text, cKey), cKey);';
var
S: string; //加密后的字符
begin
S := Encrypt(Encrypt(Encrypt(Memo1.Text, cKey1), cKey2), cKey3);
ShowMessage(S);
Memo2.Text := Decrypt(Decrypt(Decrypt(S, cKey3), cKey2), cKey1);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货