The Vigenère Cipher

The Vigenère cipher encrypts a message by using a keyword and modular arithmetic. The keyword is repeated as often as needed until there are the same number of letters as the message contains. The positions of the letters in the alphabet (a → 0, b → 1, …, z → 25) are then added to the positions of the corresponding letters in the keyword. Addition is done modulo 26, and the resulting sums are then replaced by their corresponding letters to arrive at the encrypted message. To decrypt a message, the same keyword is used, but subtraction modulo 26 is done instead of addition.
Once a message and keyword are selected, repeated use of the "next step" button illustrates the steps the Vigenère procedure. To use a new message or keyword, or to try your hand at decrypting a message, first press the "start over/new example" button. You will then be able to select a new message, a new keyword, or the decryption mode.
Selection of the decryption mode gives a random choice from a list of twelve messages distinct from the nine messages for encrypting. You can opt to decrypt an encrypted version of one of the nine original messages, if desired.
  • Contributed by: Marc Brodie
  • (Wheeling Jesuit University)


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The Vigenère cipher is a generalization of the Caesar cipher and other shift ciphers. The Caesar cipher replaces each letter in a message with the letter three letters later in the alphabet (including wrapping around to replace x with a, etc.), and thus is effectively a Vigenère cipher with keyword "d." However, the Vigenère cipher is much more difficult to crack, since it is not a simple substitution cipher—two occurrences of the same letter in a message are typically encrypted with different letters. Conversely, two occurrences of the same letter in an encrypted message typically represent two different letters in the original message. In general, the longer the keyword, the more difficult it is to crack the code.
This Demonstration includes nine messages and seven keywords to illustrate Vigenère encryption. Two single-letter keywords are included to illustrate Caesar (shift) ciphers.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+