首先感谢你的回复(Active Form 的Web Deployment option中Target URL 项能不能动态
设置),我这里有一段代码或许对你有帮助,我只需要你的e-mail,可以吗?如果行,
请把你的e-mail地址发到wcany@sina.com,以便今后再次请教!!!
加密解密算法代码:
unit Cl_crypt32;
{
*************************************************************************
*名称: Cl_crypt32.pas*
*说明: Cl_crypt32.pas为一支编解码模组,乃修改『Martin Djern犘』先生所修改
* 的《crypt32.pas 32 bits encode/decode module》而成(修改的理由请详
* 见下述)。
*
*函数原型: function cl_encrypt(s:string):string;
* function cl_decrypt(s:string):string;*
*使用方法: 《编码》encrypted:=cl_encrypt('password');
* 《解码》decrypted:=cl_decrypt(encrypted);*
*注意: 使用时,请先修改cl_crypt32.pas内StartKey,MultKey,AddKey三个key值。
* (其中startkey的值最好不要小於256)。
*
*修改的理由: 仅管『Martin Djern犘』先生的《crypt32.pas 32 bits encode/decode module》
* 已经很好用,但是我在实际应用时,却发现下列的问题:
* 1.无法把编码後的字串指定给edit元件。
* 2.无法把编码後的字串存放在.ini档内。
* 上述两点可以举下例两个例子证明:
* (例一〉
* edit1.text:=Encrypt('password',StartKey,MultKey,AddKey);
* edit2.text:=decrypt(edit1.text,StartKey,MultKey,AddKey);
* 结果: edit2.text的内容不等於'password'
* (例二)
* var
* IniFile: TIniFile;
* begin
* IniFile := TIniFile.Create('test.INI');
* IniFile.WriteString('demo', 'password', Encrypt('password',StartKey,MultKey,AddKey));
* IniFile.Free;*
* IniFile := TIniFile.Create('test.INI');
* edit2.text:=decrypt(IniFile.readString('demo', 'password', ''),StartKey,MultKey,AddKey);
* IniFile.Free;
* 结果: edit2.text的内容不等於'password'
* 上述两种情况的发生原因,大概是因为编码後的字元码大於127,
* 因此无法被『具有处理文字型态能力的元件』正确处理。
* 基於上述理由,我把它修改了一下,并加上以系统时间值为参数,
* 使其编码後的值可以成功存放在edit.text及.ini files内。
*
*修改者: cloudy@tpts4.seed.net.tw
**************************************************************************
}
{
*************************************************************************
* 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 *
* Security: avoid use StartKey less than 256 *
* if it use only for internal use you may use default *
* key, but MODIFY unit before compiling *
* Call: Encrypted := Encrypt(InString,StartKey,MultKey,AddKey) *
* Decrypted := Decrypt(InString,StartKey) *
* Parameters: InString = long string (max 2 GB) that need to encrypt *
* decrypt*
* MultKey = MultKey key *
* AddKey = Second key *
* StartKey = Third key *
* (posible use defaults from interface) *
* Return: OutString = result string *
* Editor: Besr viewed with Tab stops = 2, Courier new *
* Started: 01.08.1996 *
* Revision: 22.05.1997 - ver.2.01 converted from Delphi 1 *
* and made all keys as parameters, before only start key *
* Platform: Delphi 2.0, 3.0 *
* work in Delphi 1.0, 2^48 variants, 0..255 strings *
* Author: Anatoly Podgoretsky *
* Base alghoritm from Borland *
* Address: Vahe 4-31, Johvi, Estonia, EE2045, tel. 61-142 *
* kvk@estpak.ee *
* Status: Freeware, but any sponsor help will be appreciated here *
* need to buy books, shareware products, tools etc *
*************************************************************************
* Modified: Supports Delphi 1.0 & 2.0 *
* Overflow checking removed *
* By: Martin Djern犘 *
* e-mail: djernaes@einstein.ot.dk *
* web: einstein.ot.dk/~djernaes *
*************************************************************************
}
interface
uses
SysUtils;
const
StartKey = 71328; {Start default key}
MultKey = 88217737; {Mult default key}
AddKey = 88217767; {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) xor (StartKey shr 8));
StartKey := (Byte(Result) + 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) xor (StartKey shr 8));
StartKey := (Byte(InString) + 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),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.