← Codes you can try

Vigenère Cipher

Caesar’s cipher, with a keyword that changes the shift for every letter.

Pick a keyword. Each letter of it sets the shift for one letter of your message, over and over, so the same letter can be coded in different ways.

Don’t type real passwords or private information.

An engraved portrait of Blaise de Vigenère, a 16th-century French diplomat and cryptographer.
Portrait: Thomas de Leu, 16th century. Public domain, via Wikimedia Commons.

The Vigenère cipher tool

What would you like to do?

Use the letters A to Z. Anything else you type is dropped, and a keyword is cut off after 32 letters.

Don’t type real passwords or private information.

I How it works

How the Vigenère cipher works

A Caesar cipher moves every letter the same number of places. The Vigenère cipher moves each letter by a different number, and a keyword decides which.

Write the keyword under the message, one keyword letter for each message letter, and start again at the beginning of the keyword when it runs out. Give every letter a number, from A = 0 up to Z = 25. A message letter moves along the alphabet by the number of the keyword letter under it, and wraps round after Z.

With the keyword KING, the letter T sits over K. K is 10, so T (19) moves on 10 places to 29, and 29 wraps round to 3, which is D. The next letter, H, sits over I (8) and becomes P.

Capitals stay capitals. Spaces, punctuation, numbers and accented letters aren’t changed. The keyword moves on one letter each time a message letter is coded, and not at a space or a comma. To decrypt, move every letter back by the same number.

AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZABCDEFGHIJKLMNOPQRSTUVWXYZBCDEFGHIJKLMNOPQRSTUVWXYZACDEFGHIJKLMNOPQRSTUVWXYZABDEFGHIJKLMNOPQRSTUVWXYZABCEFGHIJKLMNOPQRSTUVWXYZABCDFGHIJKLMNOPQRSTUVWXYZABCDEGHIJKLMNOPQRSTUVWXYZABCDEFHIJKLMNOPQRSTUVWXYZABCDEFGIJKLMNOPQRSTUVWXYZABCDEFGHJKLMNOPQRSTUVWXYZABCDEFGHIKLMNOPQRSTUVWXYZABCDEFGHIJLMNOPQRSTUVWXYZABCDEFGHIJKMNOPQRSTUVWXYZABCDEFGHIJKLNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMNPQRSTUVWXYZABCDEFGHIJKLMNOQRSTUVWXYZABCDEFGHIJKLMNOPRSTUVWXYZABCDEFGHIJKLMNOPQSTUVWXYZABCDEFGHIJKLMNOPQRTUVWXYZABCDEFGHIJKLMNOPQRSUVWXYZABCDEFGHIJKLMNOPQRSTVWXYZABCDEFGHIJKLMNOPQRSTUWXYZABCDEFGHIJKLMNOPQRSTUVXYZABCDEFGHIJKLMNOPQRSTUVWYZABCDEFGHIJKLMNOPQRSTUVWXZABCDEFGHIJKLMNOPQRSTUVWXY
The Vigenère square does the adding for you: find the keyword letter’s row and the message letter’s column, and the letter where they cross is the coded letter. Here the row K and the column T cross at D, the opening letter of the KING example below.
Show the square as text

Each row starts with its keyword letter, and each column is headed by its message letter.

    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
A   A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
B   B C D E F G H I J K L M N O P Q R S T U V W X Y Z A
C   C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
D   D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
E   E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
F   F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G   G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H   H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I   I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
J   J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K   K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L   L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
M   M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
N   N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
O   O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P   P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q   Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
R   R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
S   S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
T   T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U   U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
V   V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
W   W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
X   X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
Y   Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z   Z A B C D E F G H I J K L M N O P Q R S T U V W X Y

II Many shifts

Why “Try every shift” no longer works

On the Caesar page a coded message has to be one of 25 possibilities, so you can try every shift and look for the line that reads as ordinary words. Here that fails. The keyword LEMON shifts the letters by 11, 4, 12, 14 and 13 in turn, so no single shift turns the whole message into words. A shift of 11 puts back the 1st, 6th and 11th letters and leaves the rest as nonsense.

There are also far more keys to try. A keyword of five letters can be chosen in 26 × 26 × 26 × 26 × 26 = 11,881,376 ways, against 25 shifts for a Caesar cipher.

III History

A little history

In 1553 the Italian Giovan Battista Bellaso described a cipher that switched between shifted alphabets with a repeating keyword. Simon Singh traces the ideas behind it through Alberti (born 1404), Johannes Trithemius (born 1462) and Giovanni Porta (born 1535).

The cipher is named after Blaise de Vigenère (1523–1596), a French diplomat. Singh’s account credits Vigenère with bringing those ideas together in a strong new cipher. Britannica and Wikipedia put the credit differently: both say the cipher was Bellaso’s invention and that it was credited to Vigenère afterwards, and that what Vigenère devised in 1586 was another cipher (Britannica calls it a similar one, Wikipedia a different one).

For many years the cipher was known as le chiffre indéchiffrable, “the indecipherable cipher”. Charles Babbage broke a variant of it but never published his method. Wikipedia’s articles say this was as early as 1854 and give an earlier date, 1846, for his finding of the method, so the exact story is less certain. They also say his priority was not established until 1985, after historians studied his notes. Friedrich Kasiski published a general way of breaking it in the early 1860s, in a book called Die Geheimschriften und die Dechiffrir-Kunst. Wikipedia, which cites the book, gives 1863; Britannica gives 1861, so the sources are two years apart. It is now known as the Kasiski examination.

IV The weakness

Why it falls: repeats leave patterns

The keyword repeats, so after one whole turn of the keyword the same shifts come round again. If a word such as THE meets the same part of the keyword twice, it is coded the same way twice.

With the keyword KING, THE can be coded in four ways, depending on where the keyword has got to: DPR, BUK, GNO or ZRM. Press See the weakness to code “THE SUN AND THE MAN IN THE MOON” with KING. THE becomes DPR, then BUK, then BUK again. The second and third THE are 8 letters apart, and 8 is a multiple of the keyword’s length, 4, so the keyword had gone round twice over.

A codebreaker who sees BUK twice, 8 letters apart, can guess that the keyword’s length divides 8: it could be 1, 2, 4 or 8. Other repeats rule out some of those. Singh’s cracking tool begins the same way: it hunts for groups of letters that occur more than once, since the likeliest cause is one piece of the message meeting the same piece of the keyword.

Once the length is known, say 4, every fourth letter was moved by the same shift. Each of those groups is a Caesar cipher, and counting letters can crack it.

V The lesson

The lesson

Mixing several shifts hides a message far better than one shift does, but a keyword that repeats leaves a pattern, and a pattern can be found. Use this cipher for puzzles and learning. For passwords and private messages, use modern tools.

Go back to the Caesar cipher, or crack a Caesar code by counting letters.

VI Sources

Sources

Simon Singh’s Black Chamber: The Vigenère Cipher (opens in a new tab), The Vigenère Square (opens in a new tab), Cracking Principle (opens in a new tab), Cracking the Vigenère Cipher (opens in a new tab) and its cracking tool (opens in a new tab).

For Bellaso in 1553, Kasiski in 1863, Vigenère’s dates, and the nickname: Wikipedia, “Vigenère cipher” (opens in a new tab), which cites Bellaso’s 1553 book and Kasiski’s 1863 book. For Babbage’s 1854 and 1846 dates and the year 1985: Wikipedia, “Charles Babbage” (opens in a new tab) and “Kasiski examination” (opens in a new tab). Checked 19 November 2026.

Britannica, “Vigenère cipher” (opens in a new tab), for Bellaso in 1553, Vigenère’s cipher of 1586, the nickname and Kasiski. It gives 1861 where Wikipedia gives 1863 for Kasiski, and it does not mention Babbage. Checked 19 November 2026.