看看是不是这样
function Encrypt(strSource : string):string;
var
Key1:Byte;
Key2:Byte;
bLowData:Byte;
bHigData:Byte;
i:integer;
strEncrypt:string;
strChar:string;
begin
Key1 := 65;
Key2 := 135;
for i := 1 to length(strSource) do begin
strChar := copy(strSource, i, 1);
bLowData := ord(copy(strChar, 1, 1)[1]) Xor Key1;
bHigData := ord(copy(strChar, 2, 1)[1]) Xor Key2;
strEncrypt := strEncrypt + Chr(bLowData) + Chr(bHigData);
end;
result := strEncrypt;
end;
function Encrypt(strSource : string):string;
var
Key1:Byte;
Key2:Byte;
bLowData:Byte;
bHigData:Byte;
i:integer;
strEncrypt:string;
strChar:string;
begin
Key1 := 65;
Key2 := 135;
for i := 1 to length(strSource) do begin
strChar := copy(strSource, i, 1);
bLowData := ord(copy(strChar, 1, 1)[1]) Xor Key1;
bHigData := ord(copy(strChar, 2, 1)[1]) Xor Key2;
strEncrypt := strEncrypt + Chr(bLowData) + Chr(bHigData);
end;
result := strEncrypt;
end;
function Encrypt(strSource : string):string;
var
Key1:Byte;
Key2:Byte;
bLowData:Byte;
bHigData:Byte;
i:integer;
strEncrypt:string;
strChar:string;
begin
Key1 := 65;
Key2 := 135;
for i := 1 to length(strSource) do begin
strChar := copy(strSource, i, 1);
bLowData := (((65536 + Ord(Copy(strChar, 1, 1)[1])) div 256) Mod 256) Xor Key1;
bHigData := ((65536 + Ord(Copy(strChar, 1, 1)[1])) Mod 256) Xor Key2;
strEncrypt := strEncrypt + Chr(bLowData) + Chr(bHigData);
end;
result := strEncrypt;
end;
function Encrypt(strSource : string):string;
var
Key1:Byte;
Key2:Byte;
bLowData:Byte;
bHigData:Byte;
i:integer;
strEncrypt:string;
strChar:string;
intLow : Byte;
intHigh : Byte;
intValue : integer;
begin
Key1 := 65;
Key2 := 135;
for i := 1 to length(strSource) do begin
strChar := copy(strSource, i, 1);
bLowData := (((65536 + Ord(Copy(strChar, 1, 1)[1])) div 256) Mod 256) Xor Key1;
bHigData := ((65536 + Ord(Copy(strChar, 1, 1)[1])) Mod 256) Xor Key2;
intLow := bLowData;
intHigh := bHigData;
if (intLow and $80) > 0 then
intValue := intLow * 256 + intHigh - 65536
else
intValue := intLow * 256 + intHigh;
strEncrypt := strEncrypt + Chr(intValue);
end;
result := strEncrypt;
end;
; stdcall; external 'Encrypt.dll';
; stdcall; external 'Encrypt.dll';
静态调用在implementation上加
function Encrypt(strSource : string):string; stdcall; external '动态连接库文件名//完全的路径和名称' name 'Encrypt//导出的名字';
建议string都用PChar;
动态调用:
在type 下加:
TEncrypt = function (strSource : string):string; stdcall;
在调用的函数里加
var
LibHandle : THandle;
Encrypt: TEncrypt;
begin
LibHandle := LoadLibrary('动态连接库文件名');
try
if LibHandle = 0 then
raise EDLLLoadError.Create('Unable to Load DLL');
@Encrypt := GetProcAddress(LibHandle, 'Encrypt');
if not (@Encrypt = nil) then
// 使用
finally
FreeLibrary(LibHandle);
end;
end;
静态调用在implementation上加
function Encrypt(strSource : string):string; stdcall; external '动态连接库文件名//完全的路径和名称' name 'Encrypt//导出的名字';
建议string都用PChar;
动态调用:
在type 下加:
TEncrypt = function (strSource : string):string; stdcall;
在调用的函数里加
var
LibHandle : THandle;
Encrypt: TEncrypt;
begin
LibHandle := LoadLibrary('动态连接库文件名');
try
if LibHandle = 0 then
raise EDLLLoadError.Create('Unable to Load DLL');
@Encrypt := GetProcAddress(LibHandle, 'Encrypt');
if not (@Encrypt = nil) then
// 使用
finally
FreeLibrary(LibHandle);
end;
end;