回复 70楼 ysr2857
给你的代码加了个运行时间输出,你这个判断54位的素数时间太长了,需要78秒,我记得我的那个判断300位十进制数是否为素数用时不超过10毫秒。程序代码:
Private Sub Command1_Click() Dim a, n Dim t As Double t = Timer n = Trim(Text1) If Len(n) < 6 Then Text2 = fenjieyinzi(Trim(n)) Else n1 = MPC(Trim(n), 1) a = 123 'a为明文 a1 = zzxc(Trim(n), Trim(a)) If Val(a1) > 1 Then Text2 = a1 & "*" Else c = 999 'c为公钥 Do While zzxc(Trim(n1), Trim(c)) > 1 c = Val(c - 1) Loop d = qniyuan(Trim(c), Trim(n1)) 'd为逆元为私钥 a2 = qksmimo(Trim(a), Trim(c), Trim(n)) 'a2为密文 a3 = qksmimo(Trim(a2), Trim(d), Trim(n)) If MBJC(Trim(a3), Trim(a)) = 0 Then Text2 = "这是素数有" & Len(n) & "位,用时" & Timer - t & "秒" Else Text2 = "2*2" End If End If End If End Sub
能编个毛线衣吗?