Here is the worked example I promised you. We decided to work with: p = 11 q = 7 n = 77 Phe(n) = (p-1) * (q-1) = 60 Now, you may recall we picked e=3. Turns out that you can't do this, because e must be relatively prime to Phe(n), and 3 evenly divides 60. We could have picked e=7. Now we need to find d. Recall that d = e^-1 (mod n) To calculate the inverse of e in (mod n), we use the Extended Euclid Algorithm. Like this: 60 = 1*60 + 0*7 7 = 0*60 + 1*7 From these two, we can compute: 4 = 1*60 - 8*7 (60 mod 7 = 4) Combining the last two lines we have: 7 = 0*60 + 1*7 4 = 1*60 - 8*7 From which we calculate the next line: 3 = -1 * 60 + 9*7 (3 = 7 mod 4) Now combining the last two lines: 4 = 1*60 - 8*7 3 = -1 * 60 + 9*7 We get the next line: 1 = 2*60 - 17*7 (1 = 4 mod 3) From which we can show that the answer is "43" 43 = -17 * 7^-1 (mod 60) We can prove that: 43 * 3 = 301 = 1 (mod 60) So d = 43 Let's encrypt the message "12" To encrypt, we take m^e (mod n) 12^7 = 35831808 = 48 (mod 60) Now let's decrypt "48": 48 ^ 43 = 1965048198399560713177500537391830916254451560885426333004585474449211392 = 12 (mod 60) Look at that! It works.