import numpy as np
def gen(x,e,n):
x1=modx(x,n)
for i in range(e-1):
x1=modx(x*x1,n)
return x1
def modx(x,n):
m=int(x/n)
mx=x-m*n
return mx
def cal(e,p,q):
phi=[]
for d1 in range(2,2000):
c1=e*d1
c2=(p-1)*(q-1)
c3=int(c1/c2)
c4=c1-c2*c3
if c4==1:phi.append(d1)
cx=np.random.choice(phi)
return cx
def sosu():
m1=0
while(m1<50):
p1=np.random.choice(sig)
ch=check(p1)
if ch<50:px=p1
if ch<50:m1=100
return px
def check(p1):
ch=0
for i in range(2,p1):
s1=int(p1/i)
s2=i*s1
m=p1-s2
if m==0:ch=100
return ch
sig=[]
for i in range(200):
sig.append(i+2)
p=sosu()
sig.remove(p)
q=sosu()
n=p*q
e=11
d=cal(e,p,q)
x=128
n=p*q
x1=gen(x,e,n)
print(x1)
x2=gen(x1,d,n)
print(x2)
最終更新:2018年02月09日 15:19