VBBase64编码类代码计算机等级考试

文章作者 100test 发表时间 2010:01:01 10:53:03
来源 100Test.Com百考试题网


  Attribute VB_Name = "ModBase64"
  Option Explicit
  Public key(1 To 3) As Long
  Private Const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 /"
  Public Sub GenKey()Sub GenKey()
  Dim d As Long, phi As Long, e As Long
  Dim m As Long, x As Long, q As Long
  Dim p As Long
  Randomize
  On Error GoTo top
  top:
  p = Rnd * 1000 1
  If IsPrime(p) = False Then GoTo top
  Sel_q:
  q = Rnd * 1000 1
  If IsPrime(q) = False Then GoTo Sel_q
  n = p * q 1
  phi = (p - 1) * (q - 1) 1
  d = Rnd * n 1
  If d = 0 Or n = 0 Or d = 1 Then GoTo top
  e = Euler(phi, d)
  If e = 0 Or e = 1 Then GoTo top
  x = Mult(255, e, n)
  If Not Mult(x, d, n) = 255 Then
  DoEvents
  GoTo top
  ElseIf Mult(x, d, n) = 255 Then
  key(1) = e
  key(2) = d
  key(3) = n
  End If
  End Sub
  Public Function Euler()Function Euler(ByVal a As Long, ByVal b As Long) 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

相关文章


VB中的用户界面设计计算机等级考试
计算机等级考试二级VB模拟试题十及答案解析计算机等级考试
计算机等级考试二级VB模拟试题九及答案解析计算机等级考试
VBCreateProcess模块计算机等级考试
VBBase64编码类代码计算机等级考试
VBBase64编解码计算机等级考试
VB进程权限提升代码计算机等级考试
VB获取所有逻辑磁盘信息代码计算机等级考试
VB高效连接字符串代码计算机等级考试
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛