Encrypt(50分)

B

boye

Unregistered / Unconfirmed
GUEST, unregistred user!
下面一段VB的程式用Delphi怎么写,或对应的函数是什么,恳请指教!
Private Function Encrypt(ByVal strSource As String, ByVal Key1 As Byte, _
ByVal Key2 As Integer) As String
Dim bLowData As Byte
Dim bHigData As Byte
Dim i As Integer
Dim strEncrypt As String
Dim strChar As String
For i = 1 To Len(strSource)
 ‘从待加(解)密字符串中取出一个字符
 strChar = Mid(strSource, i, 1)
 ‘取字符的低字节和Key1进行异或运算
 bLowData = AscB(MidB(strChar, 1, 1)) Xor Key1
 ‘取字符的高字节和K2进行异或运算
 bHigData = AscB(MidB(strChar, 2, 1)) Xor Key2
 ‘将运算后的数据合成新的字符
 strEncrypt = strEncrypt &
ChrB(bLowData) &
ChrB(bHigData)
Next
Encrypt = strEncrypt
End Function
 
不就是个加密函数吗?
你到网上下个加密控件不就得了!
 
简单加密函数
function Encrypt(strSource: WideString;
Key1: Byte;
Key2: integer): widestring;
var
i: Integer;
begin
Result := strSource;
For i := 1 to Length(strSource)do
begin
Result := WideChar(Integer(strSource) xor (Key2+Key1));
end;
end;
 
接受答案了.
 
顶部