We discussed **here** that the alphabet is shifted to the left one position
repeatedly to build the 26×26 Vigenère table.
This is equivalent to shift the alphabet (*i.e.*, the row heading of the Vigenère table)
to the right one position at a time.

For example, the row of **B** is obtained by
shifting the row of **A** to the left one position.
This is equivalent to shifting the alphabet to the right one position.
For the row of **B**,
**A** is shifted to
**B** and
**B** is shifted to **C**
and, hence,
**A** is encrypted to
**B** and **B**
is encrypted to **C**.
Similarly, for the row of **D**
which is three positions from **A**,
**A** is shifted three positions to
**D**,
**B** is shifted three positions to
**E**,
and **C** is shifted three positions to
**F**.
Therefore, **A**, **B**
and **C** are encrypted to
**D**, **E**
and **F** by shifting to the right three positions.
In general, if a plaintext letter ** P** is encrypted by a keyword letter

To sum it up, if the keyword is repeated enough number of times so that the total length is equal
to the length of the plaintext, for
plaintext *p*_{1}*p*_{2}...*p*_{n},
keyword *k*_{1}*k*_{2}...*k*_{n}
and ciphertext *c*_{1}*c*_{2}...*c*_{n},
we have

Decryption is the reversed procedure by shifting the ciphertext to the left. Since shifting to the left is a subtraction, the decryption procedure is simply:

With this in mind, it is very easy to program a Vigenère cipher as follows:

**An Important Note:**
In the ASCII code, letters **A** to
**Z** are consecutive
and ** K**-'