SHARE
TWEET

Untitled

a guest Nov 17th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.  
  4. def IsPrime(n):
  5.     d = 2
  6.     while n % d != 0:
  7.         d += 1
  8.     return d == n
  9.  
  10.  
  11. p = random.randint(500000, 3000000)
  12. while IsPrime(p) == False:
  13.     p = random.randint(500000, 3000000)
  14.  
  15. x = 3
  16. q = 0
  17. while x < p - 1:
  18.     if (p - 1) % x == 0:
  19.         if IsPrime(x) == True:
  20.             q = x
  21.     x = x + 1
  22. print(p)
  23. print(q)
  24. h = random.randint(1, p - 1)
  25. a = (h ** ((p-1)//q)) % p
  26. print(a)
  27. k = random.randint(2, q-1)
  28. x = random.randint(2, q-1)
  29. y = a**x % p
  30. s = input()
  31. H = 0
  32. for i in range (len(s)):
  33.     H = H + bin(ord(s[i])).count('1')
  34. print(H)
  35. r = a**k % p % q
  36. s = (x * r + k * H) % q
  37. v = H**(q - 2) % q
  38. z1 = s * v % q
  39. z2 = (q - r) * v % q
  40. u = ((a**z1 * y**z2) % p) % q
  41. print(u, r)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top