Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. n_pour_dh = 71632723108922042565754944705405938190163585182073827738737257362015607916694427702407539315166426071602596601779609881448209515844638662529498857637473895727439924386515509746946997356908229763669590304560652312325131017845440601438692992657035378159812499525148161871071841049058092385268270673367938496513
  2. e_pour_dh = 1009
  3.  
  4. p = 1068522512900119147557173208241671116649415470577282880246316447896772822847296055763408358990225038564394875651124083651221230420679921054094436578154107
  5. q = 67039039649712985497870124991029230637396829102961966888617807218608820150367734884009371490834517138450159290932430254268769414059732849732168245030420659
  6.  
  7. qdh_chiffre_avec_RSA = 70785482415899901219256855373079758876285923471951840038722877622097582944768442919300478197733262514534911901131859013939654902078384994979880540719293485131574905521151256806126737353610928922434810670654618891838295876181905553857594653764136067479449117470741836721372149447795646290103141292761424726007
  8. pdh_chiffre_avec_RSA = 55044587110698448189468021909149190373421069219506981148292634221985403129928367209713497911359302701069378532959510957622709061077384648566361893749771744973388835727259855002207844685526295296408852878202498675158924213264474587673461598376054133832370354928763624202425050121409987087150490459351809040858
  9. gdh_chiffre_avec_RSA = 43089172300844684958445369204000423742543038862350925279569289644298734265625491619486408239703259462606739540181409010715678916496299388069246398890469779970287613357772582024703107603034996120914490203805569384580718393586094166173301167583379300330660182750028000520221960355249560831414918130647224546308
  10.  
  11.  
  12. phi_n = (p-1)*(q-1)
  13.  
  14. def gcd(a, b):
  15. if (a < b):
  16. t = a
  17. a = b
  18. b = t
  19. r = a % b
  20. while (r != 0):
  21. a = b
  22. b = r
  23. r = a % b
  24. return b
  25.  
  26. def factor(n,b):
  27. """ Factor using Pollard's p-1 method """
  28.  
  29. a = 2;
  30. for j in range(2,b):
  31. a = a**j % n
  32.  
  33. d = gcd(a-1,n);
  34. print "d:",d,"a-1:",a-1
  35. if 1 < d < n: return d;
  36. else: return -1;
  37.  
  38. MMI = lambda A, n,s=1,t=0,N=0: (n < 2 and t%N or MMI(n, A%n, t, s-A//n*t, N or n),-1)[n<1]
  39.  
  40. d = (MMI(e_pour_dh, n_pour_dh))%phi_n;
  41.  
  42. qdh = (qdh_chiffre_avec_RSA^d)%n_pour_dh;
  43. pdh = (pdh_chiffre_avec_RSA^d)%n_pour_dh;
  44. gdh = (gdh_chiffre_avec_RSA^d)%n_pour_dh;
  45.  
  46. print("d = %s" %(d))
  47. print("qdh = %s " %(qdh))
  48. print("pdh = %s " %(pdh))
  49. print("gdh = %s " %(gdh))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement