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;
解决方案 »
- 我一电脑安装多台打印机时,delphi6 自带Qreport报表打印如果指定打印机!
- 请问高手:部分电脑上运行时出现“Access violation at 006A1E66 in module 'JhBuyer.exe'. Read of address 00000020”是什么原因
- 如何修改EXE??????
- 按揭散分!调查笔记本电脑拥有率和是否值得购买!散分为主。
- 邮件程序,急用,up有分。
- 怎么实现冰河的网络传输机制(就是怎么实现在不同的局域网或者internet来进行网络传输)?
- 如何得到更新的记录?(在先等待......)
- ####快来看那!!
- 路过的,进来帮帮忙的,谢谢了
- 用什么控件可以显示word文档,我用opendialog得到文件名,想在窗体内显示出来
- MEMO怎么删除我选择的行呢?
- 现在我想往word插入文档(比如表格)用com好还是DDE好?
function StringToFile(mString: string; mFileName: TFileName): Boolean;
var
vFile: file of Char;
I: Integer;
begin
{$I-}
AssignFile(vFile, mFileName);
Rewrite(vFile);
for I := 1 to Length(mString) do Write(vFile, mString[I]);
CloseFile(vFile);
{$I+}
Result := (IOResult = 0) and (mFileName <> '');
end; { StringToFile }function FileToString(mFileName: TFileName): string;
var
vFile: file of Char;
vChar: Char;
begin
Result := '';
{$I-}
AssignFile(vFile, mFileName);
Reset(vFile);
while not Eof(vFile) do begin
Read(vFile, vChar);
Result := Result + vChar;
end;
CloseFile(vFile);
{$I+}
end; { FileToString }