ucrypt.pas
来自「《Delphi通用模块及典型系统开发实例导航》配套光盘第一章(数据库加密)」· PAS 代码 · 共 37 行
PAS
37 行
unit uCrypt;
interface
const
C1 = 52845;
C2 = 22719;
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: byte;
begin
SetLength(Result, Length(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;
end;
function Decrypt(const S: string; Key: Word): string;
var
I: byte;
begin
SetLength(Result, Length(S));
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;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?