u_encrypt.pas
来自「完整的进销存系统。 设计文件及完整的源代码。 Delphi6.0」· PAS 代码 · 共 47 行
PAS
47 行
unit u_encrypt;//加密單元
interface
uses
classes;
const
C1:integer=12345;
C2:integer=54321;
//=================
g_pwdkey: Integer=888888;
function Encrypt(const S: string; Key: Word): string;
function Decrypt(const S: string; Key: Word): string;
implementation
function Encrypt(const S: string; Key: Word): string;//加密
var
I: Integer;
begin
Result := S;
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 13));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
if Result='' then
Result:='ERP';
end;
function Decrypt(const S: string; Key: Word): string;//解密
var
I: Integer;
begin
Result := S;
if Result='ERP' then begin Result:=''; exit; end;
for I := 1 to Length(S) do
begin
Result[I] := char(byte(S[I]) xor (Key shr 13));
Key := (byte(S[I]) + Key) * C1 + C2;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?