The RSA algorithm is currently the most widely studied asymmetric encryption algorithm. The security of this algorithm is based on the large number decomposition problem. It has resisted a large number of attacks in the past. The specific description of the algorithm for RSA key generation and encryption and decryption as follows:
(1) Select two large prime numbers p and q;
(2) Calculate n=p q, z=(p-1) (q-1); here, the length of n converted into binary is the key length, typical value It is 1024 bits;
(3) Choose a number that is relatively prime to z, and record it as d;
(4) Find e that satisfies e*d=1modz;
(5) That is, the public key is (e, n), and the private key is (d , n);
(6) Divide the plaintext to be encrypted into blocks, so that the plaintext message P of each block falls in the interval 0<=P<n. Ciphertext C=P^e(mod n);
(7) Plaintext P=C^d(mod n).