(CD) mod (P * Q)
For example,
P = 11
Q = 3
E = 3
D = 7
To encrypt the number 5 calculate (53 mod (11 *3))
== (5 * 5 * 5 mod 33) == (125 mod 33) == 26
To decrypt the number 26 calculate (267 mod (11 * 3
))
== (26*26* 26 *26*26*26*26 mod 33)
==(8031810176 mod 33)== 5
The public key is the pair of numbers (P * Q, E) or (33, 3) and the private key is (D) or the
number 7. In fact, these are the smallest numbers we can choose
and the formula is very easy to calculate by hand. This example could not be
used as a very good cipher - many numbers in the range (0
to 33) encrypt to exactly the same value. Although the
modulus (P *Q) is never published as a pair of prime
numbers, it is easy to guess that 33 can only factored to
3 and 11 and with this information it is
possible to deduce the private key.
Picking the numerically larger value to be
d allows implementing code to take advantage of certain
computational improvements to be had in the encryption/decryption arithmetic if
the original values of p and q are available, as they could be for
the "private" key
RSA becomes very difficult indeed
to
crack when much larger pair of prime numbers are chosen. Blocks
of 128 bytes at time can be encrypted using a 1024 bit key. In this case, two
prime 512 bit prime numbers are used to calculate the modulus. Given the modulus
from a public key, a brute force scan for a suitable pair of primes will
take more time than is left in the universe (It
is possible that the
CIA know better)