# Encryption and decryption example using the Pohlig-Hellman Exponentiation Cipher

Let $n=11, d=3, e=7$ and $M=3$.

Encryption:

  M = BSK
B -> 1 , S -> 18 -> k -> 10
M1 => C1 = 1^7 mod 11 = 1
M2 => C2 = 18^7 mod 11 = 6
M3 => C3 = 10^7 mod 11 = 10

C = 1 6 10
<=>
1=>B, 6=>G 10=>K


Decryption:

  C1 => M1 = 1^3 mod 11 = 1
C2 => M2 = 6^3 mod 11 = 18
C3 => M3 = 10^3 mod 11 = 10

M = BSK


I would like to know that I am correctly doing encryption and decryption?

Using the Pohlig-Hellman cipher, you encrypt your message $M = 3$ using an encryption key $(e,n) = (7,11)$. The encryption is $C = M^e \mod n = 3^7 \mod 11=9$.
You decrypt with a decryption key $(d,n) = (3,11)$, such that $e\cdot d = 1 \mod (n-1)$. Since $3 \cdot 7 \mod (11-1) \equiv 21 \mod 10 \equiv 1$, this is satisfied.
So, to decrypt, compute $9^3 \mod 11 \equiv 3$, which was your $M$. You're done.
You use the Pohlig-Hellman algorithm when you want to solve $g^x = h \mod p$, where $g,h$ are in a finite field $\mathbb{F}^*_p$, $g$ is a primitive root and $p$ is a prime. When $p-1$ factors into a bunch of small primes, you can solve several smaller discrete logarithm problems and reassemble $x$ from the solutions to those smaller problems via the Chinese remainder theorem.