# Key Cryptography

RSA encryption can be used for many things such as keeping important messages secured. It is very difficult to break or decode messages that have been encrypted by RSA encryption if not given a public key. There are a few steps that one must go through in order to encrypt and decrypt a message.

We can look at few variables that are needed through the RSA encryption process:

$$e$$ will be our public key
$$d$$ is the value used for decoding and is only given to the receiver
$$p$$ and $$q$$ are the primes
$$n$$ is the result of ﻿$$pq$$
$$M$$ is the original message
$$C=M^e$$ (mod $$n$$) is used to encrypt messages
$$C^d$$ (mod $$n$$) is used to decrypt messages﻿

In order to encrypt a message, primes $$p$$ and $$q$$ are to be chosen. We can compute $$n$$ by multiplying, $$pq$$. The value of $$n$$ is the value that is made public, however the primes $$p$$ and $$q$$ are kept a secret. Next $$\phi n$$ is calculated also denoted as $$\phi n=\left(p-1\right)\left(q-1\right)$$. Afterwards, the value $$d$$ is chosen, and $$d$$ has to be relatively prime to $$\phi n$$, this can be done using Euclidean algorithm. The algorithm then shows how $$e$$ is found by using the equation $$de+\phi nf=1$$. The value of $$e$$ is made public while the value of $$d$$ is kept a secret.

Seeing an example can be more helpful. Let’s say that $$p=7$$ and $$q=17$$, $$n$$ can be computed by $$pq$$ and in our case $$pq=119$$. To calculate $$\phi n$$ we do $$\left(7-1\right)\left(17-1\right)$$