The Vigenère cipher () is a method of encrypting alphabetic text where each letter of the plaintext is encoded with a different Caesar cipher, whose increment is determined by the corresponding letter of another text, the key. In a Caesar cipher, each letter of the alphabet is shifted along some number of places. In a Caesar cipher of shift 3, a would become D, b would become E, y would become B and so on. The Vigenère cipher has several Caesar ciphers in sequence with different shift values.

For example, if the plaintext is attacking tonight and the key is oculorhinolaryngology, then

the first letter of the plaintext, a, is shifted by 14 positions in the alphabet (because the first letter of the key, o, is the 14th letter of the alphabet, counting from zero), yielding o;

the second letter, t, is shifted by 2 (because the second letter of the key, c, is the 2nd letter of the alphabet, counting from zero) yielding v;

the third letter, t, is shifted by 20 (u), yielding n, with wrap-around; and so on.

Traditionally spaces and punctuation are removed prior to encryption and reintroduced afterwards.

In this example the tenth letter of the plaintext t is shifted by 14 positions (because the tenth letter of the key o is the 14th letter of the alphabet, counting from zero). Therefore, the encryption yields the message ovnlqbpvt hznzeuz.

If the recipient of the message knows the key, they can recover the plaintext by reversing this process.

The Vigenère cipher is therefore a special case of a polyalphabetic substitution.

First described by Giovan Battista Bellaso in 1553, the cipher is easy to understand and implement, but it resisted all attempts to break it until 1863, three centuries later. This earned it the description le chiffrage indéchiffrable (French for 'the indecipherable cipher'). Many people have tried to implement encryption schemes that are essentially Vigenère ciphers. In 1863, Friedrich Kasiski was the first to publish a general method of deciphering Vigenère ciphers.

In the 19th century, the scheme was misattributed to Blaise de Vigenère (1523–1596) and so acquired its present name.

History The very first well-documented description of a polyalphabetic cipher was by Leon Battista Alberti around 1467 and used a metal cipher disk to switch between cipher alphabets. Alberti's system only switched alphabets after several words, and switches were indicated by writing the letter of the corresponding alphabet in the ciphertext. Later, Johannes Trithemius, in his work Polygraphia (which was completed in manuscript form in 1508 but first published in 1518), See pp. 121–122. invented the tabula recta, a critical component of the Vigenère cipher. Available at: George Fabyan Collection (Library of Congress; Washington, D.C., U.S.A.) (Note: The pages of this book are not numbered.) The Trithemius cipher, however, provided a progressive, rather rigid and predictable system for switching between cipher alphabets.In a separate manuscript that Trithemius called the Clavis Polygraphiae (The Key to the Polygraphia), he explained (among other things) how to encipher messages by using a polyalphabetic cipher and how to decipher such messages. The Clavis Polygraphiae was not always included in the original 1518 printed copies, and even when it was included, it wasn't always inserted in the same location in the Polygraphiae. From (Gamer, 2015), p. 129: "Eine eigene Stellung innerhalb … in den Ausführungen zu Buch VI." (The Clavis occupies a peculiar place within the text that's been passed down only in print. Trithemius alludes several times in other places to the existence of a Clavis Polygraphiae as a separate work, contemporaneous with the manuscript of 1508. However, we know only the edition that is bound with the printed version, which was sporadically adapted to changes during printing, as often as not – as, for example, in the case of the shifted chapter on alphanumeric number notation. The Clavis didn't accompany this relocation: the explanations of the representations of numbers remained in the remarks on Book VI.)

The Clavis explains how to encipher and decipher messages by using polyalphabetic ciphers. In Trithemius' examples, he decoded a message by using two Vigenere tables – one in which the letters are in normal alphabetical order and the other in which the letters are in reversed order (see (Gamer, 2015), p. 128). From (Trithemius, 1518), pp. 19–20:

Original Latin text: "In primis tabulam descripsimus rectam, alphabeta quatuor & viginti continentem, per cuius intelligentiam tot poterunt alphabeta componi, quot stellae numerantur in firmamento caeli. Quot enim in ipsa tabula sunt grammata, totiens consurgunt ex arte decies centena milia per ordinem alphabeta. Post haec tabulam distribuimus aversam, quae totiens consurget in aliam, quotiens literam mutaveris a capite primam. Est autem litera prima in tabula recta b, & in aversa z. In quarum locum quotiens reposueris quamlibet aliam variatam totiens invenies tabulam per omnia novam, & ita usque ad infinitum. Deinde primam tabulam rectam expandimus, unicuique literae transpositae nigrae illam quam repraesentat ad caput eius cum minio collocantes, ut modum scribendi faciliorem lectori praeberemus. Est autem modus iste scribendi, ut in primo alphabeto nigro, capias occultae sententiae literam unam, de secundo aliam, de tertio tertiam, & sic consequenter usque ad finem. Quo cum perveneris, totiens ad ordinem primum redeundum memineris, quousque mentis tuae secretum mysterium occultando compleveris. Verum ut ordinem videas, ponamus exemplum. Hxpf gfbmcz fueib gmbt gxhsr ege rbd qopmauwu. wfxegk ak tnrqxyx. Huius mystici sermonis sententia est. Hunc caveto virum, quia malus est, fur, deceptor, mendax & iniquus. Cernis iam nunc lector quam mirabilem transpositionem literarum alphabeti haec tabula reddat, cum sit nemo qui sine noticia eius hoc valeat penetrare secretum. Exedit enim modus iste scribendi omnem transpositionem literarum communem, cum unaquaeque litera semper de una serie alphabeti mutetur in aliam. Ex tabula quoque aversa quam simili distributione per ordinem expandimus, pro introductione tale ponamus exemplum. Rdkt, stznyb, tevqz, fnzf, fdrgh, vfd. Cuius arcani sensus est talis, Hunc caveto virum, quia malus [est]. Et nota quod sub exemplo tabulae recte iam posito seriem occultam a principio per totum eius deduximus, & deinceps continuando similiter per aversam, rursusque circulum facimus, ut cernis ad principium tabulae rectae." English translation: In the first [illustration], we have transcribed a regular table [i.e., tabula recta, a table in which the letters of alphabet are listed in their normal order; see (Trithemius, 1518), p. 471.) containing 24 alphabets [Note: Trithemius used alphabets containing only 24 letters by setting j=i and v=u.], by which knowledge they will be able to compose as many alphabets as stars are numbered in the firmament of heaven. For in the table itself there are as many letters as arise by [applying] skill – a million per alphabetical row. [That is, the letters in the table need not be listed in alphabetical order, so many enciphering tables can be created.] After this, we arrange [the alphabets in] the reverse table [i.e., tabula aversa, a table in which the letters of the alphabet are listed in reverse order; see (Trithemius, 1518), p. 472.), which will arise in the other [reversed table] as many times as you will have changed [i.e., permuted] the first letter of the top [of the regular table]. And so the first letter in the regular table is b, and z in the reverse [table]. As often as you will have put in its place another changed [table], you will find a new table for everything, and so on indefinitely. [That is, again, many enciphering tables can be created.] Next we explain the first regular table: it shows how it is assigning, to each transposed black letter, [a letter] in red [ink along] its [i.e., the table's] top [border], in order to show to the reader an easier way of writing [i.e., of deciphering messages]. And that is a way of writing so that in the first black alphabet [i.e., an alphabet printed in the table using black, not red, ink], you will get one letter of the hidden sentence [i.e., the deciphered message]; from the second [black alphabet], another [deciphered letter]; from the third [black alphabet], a third [deciphered letter]; and thus accordingly until the end. You will have arrived there [i.e., at the end] when you will have recalled returning many times to the first row, until you will have completed concealing the secret mystery of your thought. [That is, the message is deciphered by deciphering its first 24 letters by using the tabula recta, then repeating the procedure by using the same tabula recta to decipher the next 24 letters of the message, and so on.] However, so that you [can] see the sequence [i.e., procedure], we present an example: Hxpf gfbmcz fueib gmbt gxhsr ege rbd qopmauwu wfxegk ak tnrqxyx. The meaning of this mystical sentence is: Hunc caveto virum, quia malus est, fur, deceptor, mendax et iniquus. (Beware of this man, who is bad, a thief, a deceiver, a liar, and unjust.) You already discern now, reader, how this table renders an astonishing transposition of the letters of the alphabet, because there is no one who, without acquaintance of this, can penetrate the secret. For that method of writing corrodes every transposition of common letters, because each and every letter of one sequence of the alphabet is always changed into another [letter]. Likewise, we explain how [to decipher a message], by means of the sequence [i.e., the deciphering procedure], from the reverse table with a similar arrangement [of letters]; as an introduction, we present such an example: Rdkt, stznyb, tevqz, fnzf, fdrgh, vfd. The secret meaning of which is such: Hunc caveto virum, quia malus [est]. (Beware of this man, who is bad.) And note about the example of the regular table [that was] already presented [i.e., the example that began with Hxpf], that we derived the secret series [i.e., the deciphered message] from the beginning through all of it [i.e., of the regular table], and thereafter by continuing similarly by means of the reverse [table], and again we make a circle, so that you are looking at the beginning of the regular table. [That is, the message is deciphered by using the regular table, but if the message is longer than 24 characters, then the decipherment continues by using the reverse table, and if necessary, one continues to decipher by returning to the regular table – and so forth.]

In 1586 Blaise de Vigenère published a type of polyalphabetic cipher called an autokey cipher – because its key is based on the original plaintext – before the court of Henry III of France. The cipher now known as the Vigenère cipher, however, is based on that originally described by Giovan Battista Bellaso in his 1553 book La cifra del Sig. Giovan Battista Bellaso. Available at: Museo Galileo (Florence (Firenze), Italy) He built upon the tabula recta of Trithemius but added a repeating "countersign" (a key) to switch cipher alphabets every letter.

Whereas Alberti and Trithemius used a fixed pattern of substitutions, Bellaso's scheme meant the pattern of substitutions could be easily changed, simply by selecting a new key. Keys were typically single words or short phrases, known to both parties in advance, or transmitted "out of band" along with the message, Bellaso's method thus required strong security for only the key. As it is relatively easy to secure a short key phrase, such as by a previous private conversation, Bellaso's system was considerably more secure.