title: programmatically generate `d` from `p` and `q` (RSA)
body: <p>I have two numbers, <code>p</code>, and <code>q</code>. I know that I can get <code>phi = (p-1)*(q-1)</code> and that <code>ed = 1 (mod phi)</code>... but I'm not sure I get what this means.</p>
  
  <p>I wrote some Python:</p>
  
  <pre><code>p = NUM
  q = NUM
  e = NUM
  phi = (p-1)*(q-1)
  d = (1 % phi)/float(e)
  </code></pre>
  
  <p>But I always get a decimal, and <code>d</code> is supposed to be an integer. what am I doing wrong?</p>
  
  <p>EDIT: I may just not understand RSA. Right now, I'm looking at this page: <a href="http://www.di-mgt.com.au/rsa_alg.html" rel="nofollow">http://www.di-mgt.com.au/rsa_alg.html</a></p>