And, as we know, the RSA modulus r is used later on in the encryption and decryption processes. r = p* q (remember that the fundamental basis of the RSA Asymmetric Encryption Process is the fact that it is extremely easy to compute the RSA modulus r = p*q, but very difficult to reverse). Once we have the two (different) prime numbers, we should calculate the RSA modulus r. We need to ensure that the two prime numbers generated are different. SymPy has a method called randprime() that can generate a random prime between two numbers.
We are going to use the SymPy built-in Python module. The very first step is to generate two prime numbers, p and q.
Implementing the RSA Asymmetric Encryption Process in Python The code has been broken down into three distinct tasks - Key Generation, Encryption and Decryption. This technical article walks the reader through the Python code that can be used to implement the RSA Asymmetric Encryption Process.