how rsa keys are generated?
Key generation. The keys for the RSA algorithm are generated in the following way: Choose two distinct prime numbers p and q. For security purposes, the integers p and q should be chosen at random, and should be similar in magnitude but differ in length by a few digits to make factoring harder.