📄 encode.~pas
字号:
unit Encode;
interface
function Encrypt(const str: string): string;
function Decrypt(const str: string): string;
implementation
{#### 加密解密}
const
fSeedA = 56789;/// 常量 ,
fSeedB = 54667; /// 常量 ,
fKey = 1106; // 钥匙
function Encrypt(const str: string): string;
var
i, j, iKey: Integer;
strGet: string;
begin
strGet := str;
iKey := FKey;
Result := strGet;
for i := 1 to Length(strGet) do
begin
Result[i] := Char(byte(strGet[i])xor(iKey shr 8));
iKey := (Byte(Result[I]) + iKey) * FSeedA + FSeedB;
end;
strGet := Result;
Result := '';
for i:=1 to Length(strGet) do
begin
j := Integer(strGet[i]);
Result := Result + Char(65+(j div 26))+ char(65+(j mod 26));
end;
end;
function Decrypt(const str: string): string;
var
i, j, iKey: Integer;
strGet: string;
begin
strGet := str;
iKey := FKey;
Result := '';
for i := 1 to (Length(strGet) div 2) do
begin
j := (Integer(strGet[2*i-1])-65)*26;
j := j + (Integer(strGet[2*i])-65);
Result := Result + Char(j);
end;
strGet := Result;
for i := 1 to Length(strGet) do
begin
Result[i] := Char(byte(strGet[I]) xor (iKey shr 8));
iKey := (Byte(strGet[I]) + iKey) * FSeedA + FSeedB;
end;
end;
{#############}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -