DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: randy522732557
今日帖子: 21
在线用户: 13
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 hongama (hongama) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 12:54:06
标题:
编写这样的dll 浏览:1277
加入我的收藏
楼主: 有这么个问题,用dll来记录连接数据库的信息,其中有数据库服务器名,数据库名,帐号和密码,怎么实现,给个思路先!谢了
----------------------------------------------
-
作者:
男 root_lh (Lhxs) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 13:33:42
1楼: 你看看dll中的共享数据怎么用吧。这方用得很少。。
----------------------------------------------
中流一壶,千金争挈。宁为铅刀,毋为楮叶。错节盘根,利器斯别。识时务者,呼为俊杰!
作者:
男 hongama (hongama) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 13:34:57
2楼: 有没有例子,给一个,或给个思路
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/3/24 13:40:08
3楼: 记录自己的还是别人的程序

自己的用静态调用然后INI保存

别人的用钩子!
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 hongama (hongama) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 14:28:20
4楼: 关键是老大要我把记录的文件改成别人打开时出现乱码,你要是用ini来实现
打开时肯定不是乱码了,ini保存的我现在都做完了,我需要的是实现乱码的
功能,有没有办法?记录的是登陆SQL server2000数据库的服务器名,数据库
名,帐号和密码.
----------------------------------------------
-
作者:
男 bianfuxia888999 (bfx) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 14:38:34
5楼: 给ini文件加个密不就得了吗
----------------------------------------------
-
作者:
男 hongama (hongama) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 15:02:51
6楼: 你知道怎么加密吗?给我发一个,msn:hongyanchang521@hotmail.com
谢谢!
----------------------------------------------
-
作者:
男 hongama (hongama) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 16:00:51
7楼: 各位不用了,加密和解密都有了。
----------------------------------------------
-
作者:
男 hongama (hongama) ★☆☆☆☆ -
盒子活跃会员
2004/3/24 16:03:27
8楼: 贴一下吧,免的有人又和我一样:unit EZCrypt; 

{modeled by Ben Hochstrasser(bhoc@surfeu.ch) after some code snippet from borland} 

interface 

uses Windows, Classes; 

type 
  TWordTriple = Array[0..2] of Word; 

function FileEncrypt(InFile, OutFile: String; Key: TWordTriple): boolean; 
function FileDecrypt(InFile, OutFile: String; Key: TWordTriple): boolean; 
function TextEncrypt(const s: string; Key: TWordTriple): string; 
function TextDecrypt(const s: string; Key: TWordTriple): string; 
function MemoryEncrypt(Src: Pointer; SrcSize: Cardinal; Target: Pointer; TargetSize: Cardinal; Key: TWordTriple): boolean; 
function MemoryDecrypt(Src: Pointer; SrcSize: Cardinal; Target: Pointer; TargetSize: Cardinal; Key: TWordTriple): boolean; 

implementation 

function MemoryEncrypt(Src: Pointer; SrcSize: Cardinal; Target: Pointer; TargetSize: Cardinal; Key: TWordTriple): boolean; 
var 
  pIn, pOut: ^byte; 
  i : Cardinal; 
begin 
  if SrcSize = TargetSize then 
  begin 
    pIn := Src; 
    pOut := Target; 
    for i := 1 to SrcSize do 
    begin 
      pOut^ := pIn^ xor (Key[2] shr 8); 
      Key[2] := Byte(pIn^ + Key[2]) * Key[0] + Key[1]; 
      inc(pIn); 
      inc(pOut); 
    end; 
    Result := True; 
  end else 
    Result := False; 
end; 

function MemoryDecrypt(Src: Pointer; SrcSize: Cardinal; Target: Pointer; TargetSize: Cardinal; Key: TWordTriple): boolean; 
var 
  pIn, pOut: ^byte; 
  i : Cardinal; 
begin 
  if SrcSize = TargetSize then 
  begin 
    pIn := Src; 
    pOut := Target; 
    for i := 1 to SrcSize do 
    begin 
      pOut^ := pIn^ xor (Key[2] shr 8); 
      Key[2] := byte(pOut^ + Key[2]) * Key[0] + Key[1]; 
      inc(pIn); 
      inc(pOut); 
    end; 
    Result := True; 
  end else 
    Result := False; 
end; 

function TextCrypt(const s: string; Key: TWordTriple; Encrypt: Boolean): string; 
var 
  bOK: Boolean; 
begin 
  SetLength(Result, Length(s)); 
  if Encrypt then 
    bOK := MemoryEncrypt(PChar(s), Length(s), PChar(Result), Length(Result), Key) 
  else 
    bOK := MemoryDecrypt(PChar(s), Length(s), PChar(Result), Length(Result), Key); 
  if not bOK then Result := ''; 
end; 

function FileCrypt(InFile, OutFile: String; Key: TWordTriple; Encrypt: Boolean): boolean; 
var 
  MIn, MOut: TMemoryStream; 
begin 
  MIn := TMemoryStream.Create; 
  MOut := TMemoryStream.Create; 
  Try 
    MIn.LoadFromFile(InFile); 
    MOut.SetSize(MIn.Size); 
    if Encrypt then 
      Result := MemoryEncrypt(MIn.Memory, MIn.Size, MOut.Memory, MOut.Size, Key) 
    else 
      Result := MemoryDecrypt(MIn.Memory, MIn.Size, MOut.Memory, MOut.Size, Key); 
    MOut.SaveToFile(OutFile); 
  finally 
    MOut.Free; 
    MIn.Free; 
  end; 
end; 

function TextEncrypt(const s: string; Key: TWordTriple): string; 
begin 
  Result := TextCrypt(s, Key, True); 
end; 

function TextDecrypt(const s: string; Key: TWordTriple): string; 
begin 
  Result := TextCrypt(s, Key, False); 
end; 

function FileEncrypt(InFile, OutFile: String; Key: TWordTriple): boolean; 
begin 
  Result := FileCrypt(InFile, OutFile, Key, True); 
end; 

function FileDecrypt(InFile, OutFile: String; Key: TWordTriple): boolean; 
begin 
  Result := FileCrypt(InFile, OutFile, Key, False); 
end; 

字符串加密, 解密

----------------------------------------------
-
作者:
男 shiro (比卡丘) ★☆☆☆☆ -
普通会员
2004/3/24 16:51:30
7楼: 保存成无类型文件呢?file
----------------------------------------------
巧克力PIKA
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行85.9375毫秒 RSS