⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucrypt.pas

📁 《Delphi通用模块及典型系统开发实例导航》配套光盘第一章(数据库加密)
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -