### Vigenère Cipher

#### Background

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 chiffre 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. (thx wiki). Hack it here

The Vigenère cipher is "related" to the Caesar cipher, but because it uses a number of substitutions (2 or more), it is technically a "POLYALPHABETIC Cipher.

The "key" is a phrase that both the sender and receiver knows.

The "Tableau" (2 character lookup table) that a Vigenère cipher uses can be envisaged as follows:

Example:

 ClearText: Key: CipherText W E A T T A C K A T D A W N A L E R T A L E R T A L E R T A L W P R M Y L G B A E U T W Y

As keylength goes up, the number of possible substitutions needed to be brute-force checked skyrockets:

stolen from Tutorials Point

Code

#### Let's try it out:

 Key: Message:

#### Algorithm

```#Thanks Greg Egan for the Pseud starter
BEGIN
SET cryptText=''
SET keyIndex = 0
SET alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
INPUT mode
INPUT upcase(message)
INPUT upcase(key)
SET keyLength = length of key

FOR each char in message:
IF char not in alphabet THEN
CALCULATE cryptText += char
ELSE
SET letterPos = position of char in alphabet

SET keyChar = key[keyIndex]
SET keyPos = position of keyChar in alphabet

IF mode = 'encrypt' THEN
CALCULATE newIndex = (letterPos + keyPos) mod 26
ELSE
CALCULATE newIndex = (letterPos - keyPos) mod 26
ENDIF

CALCULATE keyIndex = (keyIndex + 1) mod keyLength
SET cryptText += alphabet[newIndex]
ENDIF
ENDFOR

PRINT cryptText
END```

#### Variations

It seems both the Gronsfeld and Beaufort ciphers are variations of Vigenère - read a paper I stole from https://www.nku.edu/~christensen/092hnr304%20Gronsfeld%20and%20Beaufort.pdf about these variations