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

📄 unitcommon.pas

📁 一个不错的系统
💻 PAS
字号:
unit UnitCommon;

interface

uses
  SysUtils;

const
  StartKey=956;
  MultKey=58645;
  AddKey=28564;

type
  TUsers=record
    Account:String;
    Name:String;
    Rule:String;
    Path:String;
  end;

function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
function hf_intto0str(int1:integer; len:integer):string;
function hf_chartobytestr(s:string):string;
function hf_bytetocharstr(s:string):string;
function hf_encrypt(s:string):string;
function hf_decrypt(s:string):string;
function ChkReg(s:string):boolean;

var
  BenRegistered:Boolean;
  Users:TUsers;

implementation

function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
var
  I:Byte;
begin
  Result:='';
  for I:=1 to Length(InString) do begin
    Result:=Result+CHAR(Byte(InString[I]) xor (StartKey shr 8));
    StartKey:=(Byte(Result[I])+StartKey)*MultKey+AddKey;
  end;
end;

function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
var
  I:Byte;
begin
  Result:='';
  for I:=1 to Length(InString) do begin
    Result:=Result+CHAR(Byte(InString[I]) xor (StartKey shr 8));
    StartKey:=(Byte(InString[I])+StartKey)*MultKey+AddKey;
  end;
end;

function hf_intto0str(int1:integer; len:integer):string;
var
  i,j:integer;
begin
  if length(inttostr(int1))>=len then
    result:=inttostr(int1)
  else begin
    result:='';
    i:=len-length(inttostr(int1));
    for j:=1 to i do result:=result+'0';
    result:=result+inttostr(int1);
  end;
end;

function hf_chartobytestr(s:string):string;
var
  i:byte;
begin
  result:='';
  for i:=1 to length(s) do
    result:=result+hf_intto0str(byte(s[i]),3);
end;

function hf_bytetocharstr(s:string):string;
var
  i:integer;
begin
  i:=1;
  result:='';
  if (length(s) mod 3)=0 then
    while i<length(s) do begin
      result:=result+char(strtoint(copy(s,i,3)));
      i:=i+3;
    end;
end;

function hf_encrypt(s:string):string;
var
  years, months, days, hours, mins, secs, msec:word;
  hf_StartKey, hf_MultKey, hf_AddKey: longint;
begin
  decodedate(now, years, months, days);
  decodetime(now, hours, mins, secs, msec);
  hf_StartKey:=msec;
  if hf_StartKey<256 then hf_StartKey:=hf_StartKey+256;
  hf_Multkey:=((years-1900)*12+months)*30+days+hf_StartKey*10+hf_StartKey;
  hf_AddKey:=(23*hours+mins)*60+secs+hf_StartKey*10+hf_StartKey;
  result:=hf_chartobytestr(Encrypt(hf_intto0str(hf_StartKey,3),StartKey,MultKey,AddKey))+hf_chartobytestr(Encrypt(hf_intto0str(hf_Multkey,5),StartKey,MultKey,AddKey))+hf_chartobytestr(Encrypt(hf_intto0str(hf_Addkey,5),StartKey,MultKey,AddKey))+hf_chartobytestr(Encrypt(s,hf_StartKey,hf_MultKey,hf_AddKey));
end;

function hf_decrypt(s:string):string;
var
  hf_StartKey, hf_Multkey, hf_AddKey:longint;
begin
  hf_StartKey:=strtoint(decrypt(hf_bytetocharstr(copy(s,1,9)),StartKey,MultKey,AddKey));
  hf_MultKey:=strtoint(decrypt(hf_bytetocharstr(copy(s,10,15)),StartKey,MultKey,AddKey));
  hf_AddKey:=strtoint(decrypt(hf_bytetocharstr(copy(s,25,15)),StartKey,MultKey,AddKey));
  result:=decrypt(hf_bytetocharstr(copy(s,40,length(s)-39)),hf_StartKey,hf_MultKey,hf_AddKey);
end;

function ChkReg(s:string):boolean;
begin
  Result:=s='55274-640-0000356-23069';
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -