Help me write an algorithm for encrypting files using RSA

The basic process of the RSA encryption algorithm is as follows: 1) Select two large prime numbers p and q, and calculate n=p*q; 2) Calculate the Euler function φ(n)=(p-1)(q-1); 3) Choose an integer e, requiring 1<e<φ(n), and e and φ(n) are relatively prime; 4) Calculate the integer d so that ed=1 (mod φ(n)); 5) Set the public key KU= {e,n}, private key KR={d,n}; 6) Encryption process: Assume the plaintext is M and the ciphertext is C, then C=M^e (mod n); 7) Decryption process: Assume the ciphertext is C, and the plaintext is M, then M=C^d (mod n).

Guess you like

Origin blog.csdn.net/weixin_35751194/article/details/129565391