thanhtungqng
Thành viên mới
- Tham gia
- 25/12/06
- Bài viết
- 12
- Được thích
- 7
Đây là 1 đoạn mã chương trình, yêu cầu nhập Key, Bác nào dịch hộ để có thể tính được key mình cần nhập Mình copy đoạn mã để các bác xem nhé:
Function Decrypt_dutoan(key As Long, salt As Boolean, s As String) As String
Decrypt_dutoan = StrDecode(s, key, salt)
End Function
Function Encrypt_dutoan(key As Long, salt As Boolean, s As String) As String
Encrypt_dutoan = StrEncode(s, key, salt)
End Function
Function StrEncode(ByVal s As String, key As Long, salt As Boolean) As String
Dim n As Long, i As Long, ss As String
Dim k1 As Long, k2 As Long, k3 As Long, k4 As Long, t As Long
Static saltvalue As String * 4
If salt Then
For i = 1 To 4
t = 100 * (1 + Asc(Mid(saltvalue, i, 1))) * Rnd() * (Timer + 1)
Mid(saltvalue, i, 1) = Chr(t Mod 256)
Next
s = Mid(saltvalue, 1, 2) & s & Mid(saltvalue, 3, 2)
End If
n = Len(s)
ss = Space(n)
ReDim sn(n) As Long
k1 = 11 + (key Mod 233): k2 = 7 + (key Mod 239)
k3 = 5 + (key Mod 241): k4 = 3 + (key Mod 251)
For i = 1 To n: sn(i) = Asc(Mid(s, i, 1)): Next i
For i = 2 To n: sn(i) = sn(i) Xor sn(i - 1) Xor ((k1 * sn(i - 1)) Mod 256): Next
For i = n - 1 To 1 Step -1: sn(i) = sn(i) Xor sn(i + 1) Xor (k2 * sn(i + 1)) Mod 256: Next
For i = 3 To n: sn(i) = sn(i) Xor sn(i - 2) Xor (k3 * sn(i - 1)) Mod 256: Next
For i = n - 2 To 1 Step -1: sn(i) = sn(i) Xor sn(i + 2) Xor (k4 * sn(i + 1)) Mod 256: Next
For i = 1 To n: Mid(ss, i, 1) = Chr(sn(i)): Next i
StrEncode = ss
saltvalue = Mid(ss, Len(ss) / 2, 4)
End Function
Function StrDecode(ByVal s As String, key As Long, salt As Boolean) As String
Dim n As Long, i As Long, ss As String
Dim k1 As Long, k2 As Long, k3 As Long, k4 As Long
n = Len(s)
ss = Space(n)
ReDim sn(n) As Long
k1 = 11 + (key Mod 233): k2 = 7 + (key Mod 239)
k3 = 5 + (key Mod 241): k4 = 3 + (key Mod 251)
For i = 1 To n: sn(i) = Asc(Mid(s, i, 1)): Next
For i = 1 To n - 2: sn(i) = sn(i) Xor sn(i + 2) Xor (k4 * sn(i + 1)) Mod 256: Next
For i = n To 3 Step -1: sn(i) = sn(i) Xor sn(i - 2) Xor (k3 * sn(i - 1)) Mod 256: Next
For i = 1 To n - 1: sn(i) = sn(i) Xor sn(i + 1) Xor (k2 * sn(i + 1)) Mod 256: Next
For i = n To 2 Step -1: sn(i) = sn(i) Xor sn(i - 1) Xor (k1 * sn(i - 1)) Mod 256: Next
For i = 1 To n: Mid(ss, i, 1) = Chr(sn(i)): Next i
If salt Then StrDecode = Mid(ss, 3, Len(ss) - 4) Else StrDecode = ss
End Function
Function Decrypt_dutoan(key As Long, salt As Boolean, s As String) As String
Decrypt_dutoan = StrDecode(s, key, salt)
End Function
Function Encrypt_dutoan(key As Long, salt As Boolean, s As String) As String
Encrypt_dutoan = StrEncode(s, key, salt)
End Function
Function StrEncode(ByVal s As String, key As Long, salt As Boolean) As String
Dim n As Long, i As Long, ss As String
Dim k1 As Long, k2 As Long, k3 As Long, k4 As Long, t As Long
Static saltvalue As String * 4
If salt Then
For i = 1 To 4
t = 100 * (1 + Asc(Mid(saltvalue, i, 1))) * Rnd() * (Timer + 1)
Mid(saltvalue, i, 1) = Chr(t Mod 256)
Next
s = Mid(saltvalue, 1, 2) & s & Mid(saltvalue, 3, 2)
End If
n = Len(s)
ss = Space(n)
ReDim sn(n) As Long
k1 = 11 + (key Mod 233): k2 = 7 + (key Mod 239)
k3 = 5 + (key Mod 241): k4 = 3 + (key Mod 251)
For i = 1 To n: sn(i) = Asc(Mid(s, i, 1)): Next i
For i = 2 To n: sn(i) = sn(i) Xor sn(i - 1) Xor ((k1 * sn(i - 1)) Mod 256): Next
For i = n - 1 To 1 Step -1: sn(i) = sn(i) Xor sn(i + 1) Xor (k2 * sn(i + 1)) Mod 256: Next
For i = 3 To n: sn(i) = sn(i) Xor sn(i - 2) Xor (k3 * sn(i - 1)) Mod 256: Next
For i = n - 2 To 1 Step -1: sn(i) = sn(i) Xor sn(i + 2) Xor (k4 * sn(i + 1)) Mod 256: Next
For i = 1 To n: Mid(ss, i, 1) = Chr(sn(i)): Next i
StrEncode = ss
saltvalue = Mid(ss, Len(ss) / 2, 4)
End Function
Function StrDecode(ByVal s As String, key As Long, salt As Boolean) As String
Dim n As Long, i As Long, ss As String
Dim k1 As Long, k2 As Long, k3 As Long, k4 As Long
n = Len(s)
ss = Space(n)
ReDim sn(n) As Long
k1 = 11 + (key Mod 233): k2 = 7 + (key Mod 239)
k3 = 5 + (key Mod 241): k4 = 3 + (key Mod 251)
For i = 1 To n: sn(i) = Asc(Mid(s, i, 1)): Next
For i = 1 To n - 2: sn(i) = sn(i) Xor sn(i + 2) Xor (k4 * sn(i + 1)) Mod 256: Next
For i = n To 3 Step -1: sn(i) = sn(i) Xor sn(i - 2) Xor (k3 * sn(i - 1)) Mod 256: Next
For i = 1 To n - 1: sn(i) = sn(i) Xor sn(i + 1) Xor (k2 * sn(i + 1)) Mod 256: Next
For i = n To 2 Step -1: sn(i) = sn(i) Xor sn(i - 1) Xor (k1 * sn(i - 1)) Mod 256: Next
For i = 1 To n: Mid(ss, i, 1) = Chr(sn(i)): Next i
If salt Then StrDecode = Mid(ss, 3, Len(ss) - 4) Else StrDecode = ss
End Function