简单加密解密短字符串

{
*************************************************************************
* Name:  Crypt32.Pas
* Description:  32 bits encode/decode module
* 2^96 variants it is very high to try hack
*  Purpose: Good for encrypting passwors and text
*  5:   4-  avoid use StartKey less than 256
* if it use only for internal use you may use default
* key, but MODIFY unit before compiling
* 修改下面的3个值以获得不同的加密效果
*  StartKey  = 564;    Start default key
*  MultKey  = 34656;  Mult default key
*  AddKey  = 47823;  Add default key
* function cl_encrypt(s:string):string; 加密源s,返回加密码
* function cl_decrypt(s:string):string; 解密源s,返回解密码
* Platform: work in Delphi, 2^48 variants, 0..255 strings
* 作者:cactus123456
* Email: [email protected]
*************************************************************************
}
unit Cl_crypt32;
interface
uses
  SysUtils;
const
  StartKey  = 564;    {Start default key}
  MultKey  = 34656;  {Mult default key}
  AddKey  = 47823;  {Add default key}
function cl_encrypt(s:string):string;
function cl_decrypt(s:string):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;
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;
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
		

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

7 + 2 =