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

📄 cl_crypt32.~pas

📁 基于Midas 技术的多层应用开发包第二版(带开发文档)
💻 ~PAS
字号:
unit Cl_crypt32;
unit Cl_crypt32;
interface

uses
  SysUtils;

const
  StartKey	= 956;  	{Start default key}
  MultKey	  = 58645;	{Mult default key}
  AddKey	  = 28564;	{Add default key}

function cl_encrypt(s:string):string;
function cl_decrypt(s:string):string;

//function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
//function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;

implementation

{$R-}
{$Q-}
{*******************************************************
 * Standard Encryption algorithm - Copied from Borland *
 *******************************************************}
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;
{*******************************************************
 * Standard Decryption algorithm - Copied from Borland *
 *******************************************************}
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;
{$R+}
{$Q+}

{Coded by cloudy}
Function cl_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;

{Coded by cloudy}
function cl_chartobytestr(s:string):string;
var
   i:byte;
begin
     result:='';
     for i:=1 to length(s) do
         result:=result+cl_intto0str(byte(s[i]),3);
end;

function cl_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;

{Coded by cloudy}
function cl_encrypt(s:string):string;
var
   years, months, days, hours, mins, secs, msec:word;
   cl_StartKey, cl_MultKey, cl_AddKey: longint;

begin
     decodedate(now, years, months, days);
     decodetime(now, hours, mins, secs, msec);
     cl_StartKey:=msec;
     if cl_StartKey<256 then cl_StartKey:=cl_StartKey+256;
     cl_Multkey:=((years-1900)*12+months)*30+days+cl_StartKey*10+cl_StartKey;
     cl_AddKey:=(23*hours+mins)*60+secs+cl_StartKey*10+cl_StartKey;
     result:=cl_chartobytestr(Encrypt(cl_intto0str(cl_StartKey,3),StartKey,MultKey,AddKey))+cl_chartobytestr(Encrypt(cl_intto0str(cl_Multkey,5),StartKey,MultKey,AddKey))+cl_chartobytestr(Encrypt(cl_intto0str(cl_Addkey,5),StartKey,MultKey,AddKey))+cl_chartobytestr(Encrypt(s,cl_StartKey,cl_MultKey,cl_AddKey));
end;

{Coded by cloudy}
function cl_decrypt(s:string):string;
var
   cl_StartKey, cl_Multkey, cl_AddKey:longint;
begin
   cl_StartKey:=strtoint(decrypt(cl_bytetocharstr(copy(s, 1, 9)),StartKey,MultKey,AddKey));
   cl_MultKey:=strtoint(decrypt(cl_bytetocharstr(copy(s, 10, 15)),StartKey,MultKey,AddKey));
   cl_AddKey:=strtoint(decrypt(cl_bytetocharstr(copy(s, 25, 15)),StartKey,MultKey,AddKey));
   result:=decrypt(cl_bytetocharstr(copy(s, 40, length(s)-39)),cl_StartKey,cl_MultKey,cl_AddKey);
end;


end.

⌨️ 快捷键说明

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