请问DELPHI自带的一个加密函数!!!(50分)

  • 主题发起人 主题发起人 陈桂坚
  • 开始时间 开始时间

陈桂坚

Unregistered / Unconfirmed
GUEST, unregistred user!
以前知道,现在忘记了。。请大家帮我想一下。。
 
是这个吗?
//加密函数(Copied from Borland)
function Encrypt(S: string; Key: Word): string;
var
I, j: Integer; // 用于循环
begin
Result := S; // 初始化结果字符串
for I := 1 to Length(S) do // 依次对字符串中的各个字符进行操作
begin
Result := char(byte(S) xor (Key shr 8)); // 将密匙移位后与字符异或
Key := (byte(Result) + Key) * C1 + C2 // 产生下一密匙
end;
S := Result; // 保存结果
Result := ''; // 清除结果
for I := 1 to Length(S) do // 对加密结果进行转换
begin
j := Integer(s); // 提取字符
Result := Result + Char(65 + (j div 26)) + Char(65 + (j mod 26));
end;
end;

//解密函数(Copied from Borland)
function Decrypt(S: string; Key: Word): string;
var
I, j: Integer;
begin
Result := ''; // 清除结果
for I := 1 to (length(S) div 2) do
begin
j := (Integer(S[2 * i - 1]) - 65) * 26;
j := j + (Integer(S[2 * i]) - 65);
Result := Result + Char(j);
end;
S := Result;
for I := 1 to Length(S) do
begin
Result := Char(byte(S) xor (Key shr 8));
Key := (byte(S) + Key) * C1 + C2;
end;
end;
 
我把Delphi自带的内置函数和API函数全部找了一遍没有发现你说的函数
 
有呀。。。。。我记得要引用DELPHI的一个单元。。。。
 
EncdDecd.pas

procedure EncodeStream(Input, Output: TStream);
procedure DecodeStream(Input, Output: TStream);
function EncodeString(const Input: string): string;
function DecodeString(const Input: string): string;
 
谢谢你们。。。。。[:D][:D][:D][:D][:D]
 
后退
顶部