?? pistrcrypt.pas
字號(hào):
unit piStrCrypt;
interface
uses
Classes;
const
C1 = 52845;
C2 = 22719;
function StrEncrypt( S: String; Key: Word): String;
function StrDecrypt( S: String; Key: Word): String;
implementation
//加密字符串
function StrEncrypt( S: String; Key: Word): String;
var
I: Integer;
j: Integer;
begin
Result := S;
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 StrDecrypt( 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;
//Memo1.Text:=StrEncrypt(Memo2.Text,123);
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -