Compute A^E mod N for each block, giving the encrypted version of that block.Divide it into blocks which are encoded as integers A, 1The pair (E,N) is the public key, and (D,N) is the private key.Find E's inverse mod M: an integer D such that DE ≡ 1 mod M. ![]() Take a random integer E, 1We find two large primes P and Q, and find N=PQ which will be used as a modulus.The other two functions could easily be part of rsakey() they're isolated here for clarity, and because they're somewhat useful on their own rprime() generates a random prime, and extgcd() is the extended Euclidean Algorithm.įirst, here is a description of how RSA works. Two of them are necessarily independent: rsakey() is used to generate a public and private key, and rsa() is used to encrypt or decrypt. The code for this program is divided into four parts.
0 Comments
Leave a Reply. |