Thứ Sáu, 7 tháng 1, 2011

Code mã hoá VB

Sau đây chúng tôi xin chia sẻ code mã hóa VB

Function Encrypt(ByVal inpt As String) As String
Dim temp As String
Dim tempA As String
Dim Rand As String
100:
Randomize
Rand = Right(Rnd, 3)
rad = Left(Rand, 1)
If Left(Rand, 1) = ''-'' Then
GoTo 100
End If
For i = 1 To Len(inpt)
crntASC = Asc(Mid(inpt, i, 1))
tempA = ((crntASC) Xor (Rand + i + rad)) + (i + rad)
If Len(tempA) = 4 Then
temp = temp & tempA
ElseIf Len(tempA) = 3 Then
temp = temp & ''0'' & tempA
ElseIf Len(tempA) = 2 Then
temp = temp & ''00'' & tempA
ElseIf Len(tempA) = 1 Then
temp = temp & ''000'' & tempA
End If
Next i
temp = Rand & temp
Encrypt = temp
End Function
Function Decrypt(ByVal inpt As String) As String
Rand = Left(inpt, 3)
For i = 4 To (Len(inpt) - 3) Step 4
z = z + 1
tempA = Mid(inpt, i, 4)
tempA = ((tempA - (z + Left(Rand, 1))) Xor (Rand + z + Left(Rand, 1)))
temp = temp & Chr(tempA)
Next i
Decrypt = temp
End Function
Theo diễn đàn tin học
Nguồn : Code mã hoá VB

0 nhận xét:

Đăng nhận xét