Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- v=3557
- f=2579
- N=(v-1)*(f-1)
- def gcdd(a,b):
- m1,n1=1,0
- m2,n2=0,1
- while b:
- m1,n1,m2,n2=m2,n2,m1-(a//b)*m2,n1-(a//b)*n2
- a,b=b,a%b
- return a, m1, n1
- l=[]
- def gcd(a,b=N):
- k=a
- while a!=0 and b!=0:
- if a > b:
- a = a % b
- else:
- b = b % a
- if a+b==1:
- l.append(k)
- return(l)
- for i in range(2,10000):
- gcd(i)
- e=random.choice(l)
- l.clear()
- d=gcdd(e,N)[1]
- if d<0:
- d=d+N
- print(e)
- print(d)
- B=int(input('Bob\'s text:'))
- b_c=pow(B,e,N)
- print(b_c)
- print(pow(b_c,d,N))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement