# Vigenère cipher

Calculator encrypts entered text by using Vigenère cipher. Non-alphabetic symbols (digits, whitespaces, etc.) are not transformed.

Since we already have Caesar cipher, it seems logical to add the Vigenère cipher as well. Here is the calculator, which transforms entered text (encrypt or decrypt) using Vigenere cipher.

The algorithm is quite simple. Vigenère cipher is the sequence of Caesar ciphers with different transformations (ROTX, see Caesar cipher). For example, the first letter of text is transformed using ROT5, second - using ROT17, et cetera. The sequence is defined by keyword, where each letter defines the needed shift. Phrase LEMON, for example, defines the sequence of ROT11-ROT4-ROT12-ROT14-ROT13, which is repeated until all block of text is encrypted.

As wikipedia tells us, it is a simple form of polyalphabetic substitution. The idea behind the Vigenère cipher, like all polyalphabetic ciphers, is to disguise plaintext letter frequencies, which interferes with a straightforward application of frequency analysis. For instance, if P is the most frequent letter in a ciphertext whose plaintext is in English, one might suspect that P corresponds to E because E is the most frequently used letter in English. However, using the Vigenère cipher, E can be enciphered as different ciphertext letters at different points in the message, thus defeating simple frequency analysis.

The primary weakness of the Vigenère cipher is the repeating nature of its key. If a cryptanalyst correctly guesses the key's length, then the ciphertext can be treated as interwoven Caesar ciphers, which individually are easily broken.

The running key variant of the Vigenère cipher was also considered unbreakable at one time. This version uses as the key a block of text as long as the plaintext. The problem with the running key Vigenère cipher is that the cryptanalyst has statistical information about the key elements(assuming that the block of text is in a known language) and that information will be reflected in the ciphertext.

If using a truly random key, which is at least as long as the encrypted message and is used only once, the Vigenère cipher is theoretically unbreakable. However, in this case, it is the key, not the cipher, which provides cryptographic strength, and such systems are correctly referred to collectively as one-time pad systems, irrespective of which ciphers are employed.

## Comments