title: How to compute huge numbers with python?
body: <p>I'm currently trying to find the value of x,</p>
  
  <pre><code>x = (math.log(X) - math.log(math.fabs(p))/math.log(g))
  </code></pre>
  
  <p>with :</p>
  
  <pre><code>X = 53710695204323513509337733909021562547350740845028323195225592059762435955297110591848019878050853425581981564064692996024279718640577281681757923541806197728862534268310235863990001242041406600195234734872865710114622767319497082014412908147635982838670976889326329911714511434374891326542317244606912177994106645736126820796903212224
  
  p = 79293686916250308867562846577205340336400039290615139607865873515636529820700152685808430350565795397930362488139681935988728405965018046160143856932183271822052154707966219579166490625165957544852172686883789422725879425460374250873493847078682057057098206096021890926255094441718327491846721928463078710174998090939469826268390010887
  
  g = 73114111352295288774462814798129374078459933691513097211327217058892903294045760490674069858786617415857709128629468431860886481058309114786300536376329001946020422132220459480052973446624920516819751293995944131953830388015948998083956038870701901293308432733590605162069671909743966331031815478333541613484527212362582446507824584241
  </code></pre>
  
  <p>Unfortunately python can't handle natively such big numbers.</p>
  
  <p>Does somebody know a way to solve this ?</p>
  
  <p>Thank you for your help.</p>
  
  <hr>
  
  <p>EDIT</p>
  
  <p>Since a lot you wonder what i'm trying to do:</p>
  
  <p>To be able to communicate in a secured fashion Alice and Bob proceed to a Diffie-Hellman key exchange. To that end they use the prime number p :</p>
  
  <pre><code>p = 79293686916250308867562846577205340336400039290615139607865873515636529820700152685808430350565795397930362488139681935988728405965018046160143856932183271822052154707966219579166490625165957544852172686883789422725879425460374250873493847078682057057098206096021890926255094441718327491846721928463078710174998090939469826268390010887
  </code></pre>
  
  <p>And the integer g:</p>
  
  <pre><code>g = 73114111352295288774462814798129374078459933691513097211327217058892903294045760490674069858786617415857709128629468431860886481058309114786300536376329001946020422132220459480052973446624920516819751293995944131953830388015948998083956038870701901293308432733590605162069671909743966331031815478333541613484527212362582446507824584241
  </code></pre>
  
  <p>Alice chooses the secret number x, she calculates X=g^x mod p and sends X through an unsecured channel to Bob.
  Bob chooses the secret number y, he calculates Y=g^y mod p and sends Y through the same unsecured channel to Alice.
  Both can calculate the value Z = X^y = Y^x = g^xy mod p</p>
  
  <p>By spying on the channel, Charlie retrieves the value of X and Y:</p>
  
  <pre><code>X = 53710695204323513509337733909021562547350740845028323195225592059762435955297110591848019878050853425581981564064692996024279718640577281681757923541806197728862534268310235863990001242041406600195234734872865710114622767319497082014412908147635982838670976889326329911714511434374891326542317244606912177994106645736126820796903212224
  
  Y = 17548462742338155551984429588008385864428920973169847389730563268852776421819130212521059041463390276608317951678117988955994615505741640680466539914477079796678963391138192241654905635203691784507184457129586853997459084075350611422541722123509121359133932497700621300814065254996649070135358792927275914472632707420292830992294921992
  </code></pre>
  
  <p>The key of this exercice is the md5sum of the value of Z</p>