我写了个软件 有登陆功能 登陆的时候 是连接远程的MSSQL 如何对这软件加保护 不要轻易的被别人调试出 连接SQL的IP 帐号 和密码
解决方案 »
- 面试条件:精通 Delphi 7 面向对象编程设计
- 无法将字符串'4294967295'转换成integer
- Tdbgrid 组件显示两个表的数据。
- 各位高手帮我看看
- 关于系统服务程序在启动时系统托盘显示的问题!!!请帮帮忙
- 所有窗口都可用的函数和变量是在什么地方定义?
- fastreport的打印问题
- 请问 delphi7 对.net的支持怎样
- 如何通过程序获取DLL(全部为ICO,BMP,GIF)文件中的资源文件名称.
- 我一直尝试在dbgrid中加入dbcheck,dbcombox等其它数据控件,但都没有成功.好象多数的程序员都不会.
- delphi word
- 求解如何解delphi作的程序登录密码啊
unit Cl_crypt32;
interfaceuses
SysUtils;const
StartKey = 820; {Start default key}
MultKey = 58145; {Mult default key}
AddKey = 28564; {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;
{$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.
保存为:Cl_crypt32.pas
然后引用,两个函数:cl_encrypt(s:string):string 加密
cl_decrypt(s:string):string 解密。
我理解你的意思是 用1个INI文件里保存加密后的文字 然后 程序启动后 自己调用INI中文字进行解密 我理解的对吗?
我在要连接服务器的时候先 ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Password='+quotedstr(cl_decrypt(Label10.Caption))+';Persist Security Info=True;User ID='+quotedstr(cl_decrypt(Label9.Caption))+';Initial Catalog=sq_zhiyin;Data Source= '+quotedstr(cl_decrypt(Label8.Caption));这样是不是 IP 帐号 密码 就不文明了?
如果是的话 那用截包软件 截取连接时候的封包 会是怎么样的呢