base64算法在vb(.net)中的实现

这段代码展示了如何在VB.NET中实现Base64编码和解码算法,包括公钥生成、欧拉函数、乘法运算以及IsPrime函数等关键步骤。编码函数Base64_Encode将字符串转换为Base64格式,解码函数Base64_Decode则进行反向转换。
摘要由CSDN通过智能技术生成

摘自:http://www.alixixi.com/weBuild/Subject40/weBuild/Subject40/200631911054.html
作者:[] 

  Public key(1 To 3) As Long

  Private Const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrst

  uvwxyz0123456789+/"

  Public 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

  Private Function Euler(ByVal a As Long, ByVal b As Long) As Long

  On Error GoTo error2

  r1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值