RSA is actually very simple:
1. Select two prime numbers p and q.
2. calculate n = PQ
3. Select E, so that E and (p-1) (q-1)
4. calculate d = e ^ (-1) mod (p-1) (q-1 ))
N, e is the RSA public key. You need to tell everyone who may send encrypted information,
D is the private key, only you can know.
But when someone wants to send the message m, they need to use the encryption algorithm to convert the plaintext m to the secret C
C = m ^ (E) (mod N)
After you receive the confidential C, use the decryption algorithm to convert the plaintext m
M = C ^ (D) (mod N)
Copy an example:
Take: P = 47 q = 71
So: N = PQ = 3337 P-1) (q-1) = 3220
Take: E = 79
So: D = 79 ^ (-1) mod 3220 = 1019
Encrypted plaintext M = 688
C = 688 ^ (79) (mod 3337) = 1570
Decrypt ciphertext c = 1570
M = 1570 ^ (1019) (mod 3337) = 688
That's simple. However, for security purposes, both p and q are required to be large, generally at least bits,
The generated RSA key is 1024bit.
But if you want to make it a registration code algorithm, you must put all N, E, and D in the program,
This is no different from common symmetric key algorithms.
This program is used to select P, Q, and E. These numbers are generally randomly generated, and
Verify if it is valid.
E can be fixed to 65537, which has no effect on the encryption effect.
As you can see, RSA keys are not randomly selected. They are two prime numbers from p and q.
The calculated p and q numbers must be kept strictly confidential after the keys are obtained. It is best to discard them.
RSA Security is based on the difficulty of big number decomposition, that is to say, from N to reverse obtain p, q
There is no good method before, beyond the computing power of the current computer.
Once the big data decomposition problem is solved, RSA will lose its meaning.