Sharky's Vigenere Cipher

[ Sharkysoft home ]

This page is for amusement only. Instructions are given below this form.

Coding direction:


  1. Enter the string to encrypt or decrypt in the Input field (you may copy and paste it from another text editor).
  2. Enter the key in the Key field. (You may use any sequence of characters, but only alphabetic characters will actually be processed. The key "Hey, you!" is equivalent to the key "hEyYoU".)
  3. Push the encode or decode button.
  4. Copy and paste the output into whatever application will receive it (such as your email program).

On most computers: To copy: Highlight text, press Ctrl-C; To paste: Position cursor, press Ctrl-V.


Vigenere coding is one of the most ancient forms of cryptography. In a Vigenere cipher, messages are encoded by mapping letters to numeric values and adding the plaintext values to the keytext values, modulo the number of letters in the alphabet. In this implementation, A=0, Z=25, and the modulus is 26. Despite its simplicity, the Vigenere cipher is capable of producing 100% crack-proof ciphers if used correctly. To produce an unbreakable cipher, you must:

  1. Choose a key that is as long as the plaintext message.
  2. Build the key from random characters.
  3. Never use the key again.
  4. Don't use text decorations (spaces, punctuations, capitalization).
  5. Protect the key.

Unfortunately, these steps take all the fun out of the Vigenere cipher. Most people use English words or phrases for the key (violating step 2) that are significantly shorter than the message being coded (violating step 1). Then they use the same key to encrypt additional messages (violating step 3) because they don't want to remember a new key for each message. Some people use quotations from their favorite book for the key or invent one and write it down (violating step 5). Lastly, it's no fun to handle text that doesn't look like text, so they don't remove the decorations (violating step 4). The moral of the story is that security is free, but it requires effort.

Vigenere ciphers with moderate keys are appropriate for situations that do not require failproof security. For example, Sharky uses the Vigenere cipher to encrypt sensitive passages in his personal diary. (It's good enough to deter most of the people most of the time!)

We hope you enjoy this simple JavaScript-based implementation. We had fun building it! Try using it to encrypt an email message to a friend. Rest assured that as you use it, absolutely no data will be transmitted over the Internet. (If you don't believe us, unplug your phone or network cable.)

[ Sharkysoft home ]

Copyright © 2001 Sharkysoft. All rights reserved. Last updated 2003.05.27.