Private Function Euler(ByVal a As Long, ByVal b As Long) As Long
Dim r As Long, r1 As Long, r2 As Long
Dim p As Long, p1 As Long, p2 As Long Dim q As Long, q1 As Long, q2 As Long
Dim n As Long, c As Long, s As Long, X As Long
On Error GoTo error2
r1 = a: r = b
p1 = 0: p = 1 q1 = 2: q = 0
n = -1
Do Until r = 0
r2 = r1: r1 = r
p2 = p1: p1 = p
q2 = q1: q1 = q
n = n + 1
r = r2 Mod r1
c = r2 \ r1
p = (c * p1) + p2
q = (c * q1) + q2
Loop
s = (b * p1) - (a * q1)
If s > 0 Then
X = p1
Else
X = (0 - p1) + a
End If
Euler = X
Exit Functionerror2:
Euler = 0
End FunctionPrivate Function Mult(ByVal X As Long, ByVal p As Long, ByVal m As Long) As Long
Dim Y As Long
Y = 1
On Error GoTo error1
Do While p > 0
Do While (p / 2) = (p \ 2)
X = (X * X) Mod m
p = p / 2
Loop
Y = (X * Y) Mod m
p = p - 1
Loop
Mult = Y
Exit Functionerror1:
Y = 0
Mult = Y '????
End FunctionPrivate Function IsPrime(lngNumber As Long) As Boolean
Dim lngCount As Long
Dim lngSqr As Long
Dim X As Long lngSqr = Sqr(lngNumber) ' get the int square root If lngNumber < 2 Then
IsPrime = False
Exit Function
End If lngCount = 2
IsPrime = True If lngNumber Mod lngCount = 0& Then
IsPrime = False
Exit Function
End If lngCount = 3 For X& = lngCount To lngSqr Step 2
If lngNumber Mod X& = 0 Then
IsPrime = False
Exit Function
End If
Next
End FunctionPrivate Function Base64_Encode(DecryptedText As String) As String
Dim c1, c2, c3 As Integer
Dim w1 As Integer
Dim w2 As Integer
Dim w3 As Integer
Dim w4 As Integer
Dim n As Integer
Dim retry As String
For n = 1 To Len(DecryptedText) Step 3
c1 = Asc(Mid$(DecryptedText, n, 1))
c2 = Asc(Mid$(DecryptedText, n + 1, 1) + Chr$(0))
c3 = Asc(Mid$(DecryptedText, n + 2, 1) + Chr$(0))
w1 = Int(c1 / 4)
w2 = (c1 And 3) * 16 + Int(c2 / 16)
If Len(DecryptedText) >= n + 1 Then w3 = (c2 And 15) * 4 + Int(c3 / 64) Else w3 = -1
If Len(DecryptedText) >= n + 2 Then w4 = c3 And 63 Else w4 = -1
retry = retry + mimeencode(w1) + mimeencode(w2) + mimeencode(w3) + mimeencode(w4)
Next
Base64_Encode = retry
End FunctionPrivate Function Base64_Decode(a As String) As String
Dim w1 As Integer
Dim w2 As Integer
Dim w3 As Integer
Dim w4 As Integer
Dim n As Integer
Dim retry As String For n = 1 To Len(a) Step 4
w1 = mimedecode(Mid$(a, n, 1))
w2 = mimedecode(Mid$(a, n + 1, 1))
w3 = mimedecode(Mid$(a, n + 2, 1))
w4 = mimedecode(Mid$(a, n + 3, 1))
If w2 >= 0 Then retry = retry + Chr$(((w1 * 4 + Int(w2 / 16)) And 255))
If w3 >= 0 Then retry = retry + Chr$(((w2 * 16 + Int(w3 / 4)) And 255))
If w4 >= 0 Then retry = retry + Chr$(((w3 * 64 + w4) And 255))
Next
Base64_Decode = retry
End FunctionPrivate Function mimeencode(w As Integer) As String
If w >= 0 Then mimeencode = Mid$(base64, w + 1, 1) Else mimeencode = ""
End FunctionPrivate Function mimedecode(a As String) As Integer
If Len(a) = 0 Then mimedecode = -1: Exit Function
mimedecode = InStr(base64, a) - 1
End FunctionPublic Function Encode(ByVal Inp As String, ByVal e As Long, ByVal n As Long) As String
Dim s As String
Dim m As String
Dim i As Integer
s = ""
m = Inp If m = "" Then Exit Function
s = Mult(CLng(Asc(Mid(m, 1, 1))), e, n)
For i = 2 To Len(m)
s = s & "+" & Mult(CLng(Asc(Mid(m, i, 1))), e, n)
Next i
Encode = Base64_Encode(s)
End FunctionPublic Function Decode(ByVal Inp As String, ByVal d As Long, ByVal n As Long) As String
Dim St As String, ind As String, nxt As String
Dim i As Integer, tok As Integer
St = ""
ind = Base64_Decode(Inp)
For i = 1 To Len(ind)
nxt = InStr(i, ind, "+")
If Not nxt = 0 Then
tok = Val(Mid(ind, i, nxt))
Else
tok = Val(Mid(ind, i))
End If
St = St + Chr(Mult(CLng(tok), d, n))
If Not nxt = 0 Then
i = nxt
Else
i = Len(ind)
End If
Next i
Decode = St
End Function
Dim r As Long, r1 As Long, r2 As Long
Dim p As Long, p1 As Long, p2 As Long Dim q As Long, q1 As Long, q2 As Long
Dim n As Long, c As Long, s As Long, X As Long
On Error GoTo error2
r1 = a: r = b
p1 = 0: p = 1 q1 = 2: q = 0
n = -1
Do Until r = 0
r2 = r1: r1 = r
p2 = p1: p1 = p
q2 = q1: q1 = q
n = n + 1
r = r2 Mod r1
c = r2 \ r1
p = (c * p1) + p2
q = (c * q1) + q2
Loop
s = (b * p1) - (a * q1)
If s > 0 Then
X = p1
Else
X = (0 - p1) + a
End If
Euler = X
Exit Functionerror2:
Euler = 0
End FunctionPrivate Function Mult(ByVal X As Long, ByVal p As Long, ByVal m As Long) As Long
Dim Y As Long
Y = 1
On Error GoTo error1
Do While p > 0
Do While (p / 2) = (p \ 2)
X = (X * X) Mod m
p = p / 2
Loop
Y = (X * Y) Mod m
p = p - 1
Loop
Mult = Y
Exit Functionerror1:
Y = 0
Mult = Y '????
End FunctionPrivate Function IsPrime(lngNumber As Long) As Boolean
Dim lngCount As Long
Dim lngSqr As Long
Dim X As Long lngSqr = Sqr(lngNumber) ' get the int square root If lngNumber < 2 Then
IsPrime = False
Exit Function
End If lngCount = 2
IsPrime = True If lngNumber Mod lngCount = 0& Then
IsPrime = False
Exit Function
End If lngCount = 3 For X& = lngCount To lngSqr Step 2
If lngNumber Mod X& = 0 Then
IsPrime = False
Exit Function
End If
Next
End FunctionPrivate Function Base64_Encode(DecryptedText As String) As String
Dim c1, c2, c3 As Integer
Dim w1 As Integer
Dim w2 As Integer
Dim w3 As Integer
Dim w4 As Integer
Dim n As Integer
Dim retry As String
For n = 1 To Len(DecryptedText) Step 3
c1 = Asc(Mid$(DecryptedText, n, 1))
c2 = Asc(Mid$(DecryptedText, n + 1, 1) + Chr$(0))
c3 = Asc(Mid$(DecryptedText, n + 2, 1) + Chr$(0))
w1 = Int(c1 / 4)
w2 = (c1 And 3) * 16 + Int(c2 / 16)
If Len(DecryptedText) >= n + 1 Then w3 = (c2 And 15) * 4 + Int(c3 / 64) Else w3 = -1
If Len(DecryptedText) >= n + 2 Then w4 = c3 And 63 Else w4 = -1
retry = retry + mimeencode(w1) + mimeencode(w2) + mimeencode(w3) + mimeencode(w4)
Next
Base64_Encode = retry
End FunctionPrivate Function Base64_Decode(a As String) As String
Dim w1 As Integer
Dim w2 As Integer
Dim w3 As Integer
Dim w4 As Integer
Dim n As Integer
Dim retry As String For n = 1 To Len(a) Step 4
w1 = mimedecode(Mid$(a, n, 1))
w2 = mimedecode(Mid$(a, n + 1, 1))
w3 = mimedecode(Mid$(a, n + 2, 1))
w4 = mimedecode(Mid$(a, n + 3, 1))
If w2 >= 0 Then retry = retry + Chr$(((w1 * 4 + Int(w2 / 16)) And 255))
If w3 >= 0 Then retry = retry + Chr$(((w2 * 16 + Int(w3 / 4)) And 255))
If w4 >= 0 Then retry = retry + Chr$(((w3 * 64 + w4) And 255))
Next
Base64_Decode = retry
End FunctionPrivate Function mimeencode(w As Integer) As String
If w >= 0 Then mimeencode = Mid$(base64, w + 1, 1) Else mimeencode = ""
End FunctionPrivate Function mimedecode(a As String) As Integer
If Len(a) = 0 Then mimedecode = -1: Exit Function
mimedecode = InStr(base64, a) - 1
End FunctionPublic Function Encode(ByVal Inp As String, ByVal e As Long, ByVal n As Long) As String
Dim s As String
Dim m As String
Dim i As Integer
s = ""
m = Inp If m = "" Then Exit Function
s = Mult(CLng(Asc(Mid(m, 1, 1))), e, n)
For i = 2 To Len(m)
s = s & "+" & Mult(CLng(Asc(Mid(m, i, 1))), e, n)
Next i
Encode = Base64_Encode(s)
End FunctionPublic Function Decode(ByVal Inp As String, ByVal d As Long, ByVal n As Long) As String
Dim St As String, ind As String, nxt As String
Dim i As Integer, tok As Integer
St = ""
ind = Base64_Decode(Inp)
For i = 1 To Len(ind)
nxt = InStr(i, ind, "+")
If Not nxt = 0 Then
tok = Val(Mid(ind, i, nxt))
Else
tok = Val(Mid(ind, i))
End If
St = St + Chr(Mult(CLng(tok), d, n))
If Not nxt = 0 Then
i = nxt
Else
i = Len(ind)
End If
Next i
Decode = St
End Function
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货