function Encrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
function Decrypt(const InString:string; StartKey,MultKey,AddKey:Integer): string;
implementation
{$R *.DFM}
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;
procedure Tfrm_pwd.Button1Click(Sender: TObject);
begin
edit2.Text:=Decrypt(edit3.text,StartKey,MultKey,AddKey);
//edit2.Text:=encrypt(edit3.text,StartKey,MultKey,AddKey);
end;
procedure Tfrm_pwd.Button2Click(Sender: TObject);
begin
edit3.text:=Encrypt(edit1.text,StartKey,MultKey,AddKey);
end;