Select a pair of different, large enough prime numbers p and q.
Calculate n = PQ.
Calculate F (n) = (p-1) (q-1), and keep p and q confidential, so that no one knows.
Find a number e that interacts with F (n), and 1 <e <F (n ).
Calculate d so that De has 1 Mod f (n ). This formula can also be expressed as D? E-1 Mod f (N)
Here we need to explain that attention is the symbol in number theory that represents the same remainder. In the formula, the left side of the TRIM symbol must be the same as the right side of the symbol, that is, the result of the two-side modulo operation is the same. Obviously, no matter what value F (n) gets, the result of 1 Mod f (n) on the right of the symbol is equal to 1; the result of the modulo operation on the product of D and E on the left side of the symbol must be equal to 1. In this case, the value of D needs to be calculated so that the same equality can be established.
Public Key Ku = (E, n), private key Kr = (d, n ).
During encryption, the plaintext is first converted to an integer m from 0 to n-1. If the plain text is long, it can be divided into appropriate groups and then exchanged. If the ciphertext is set to C, the encryption process is C 127m ^ e mod n.
The decryption process is m Running C ^ d mod n.
From http://bank.hexun.com/2009-06-24/118958531.html