# Vigenere Cipher Program in Java

A basic polyalphabetic substitution technique is used in the Vigenere Cypher to encrypt alphabetic text. It is more secure than a conventional Caesar cipher since it employs a keyword to move letters in the plaintext by varying amounts. In this section, we will explain the Vigenere Cypher and show you how to use it to encrypt and decode communications with a Java program.

## What is Vigenere Cypher?

The Vigenere Cipher determines the shift applied to each letter in the plaintext by employing a keyword. To match the length of the plaintext, the keyword is repeated. Every letter in the plaintext is moved by its matching letter in the keyword to encrypt a message.

### 1. Polyalphabetic Replacement

The Vigenere Cypher encrypts messages using several replacement alphabets, making it a polyalphabetic substitution cipher. A monoalphabetic substitution cipher, such as the Caesar Cypher, on the other hand, only makes use of one substitution alphabet.

### 2. Key and Key Repetition

The Vigenere Cipher's key is what makes it so strong. A word or phrase known as the "key" is what decides which letters to shift during encryption. The Vigenere Cypher moves each letter according to its matching letter in the key, as opposed to the Caesar Cypher, which steadily shifts each letter. A repeating pattern is produced when the key is frequently repeated to match the length of the plaintext. Compared to straightforward replacement ciphers, cryptanalysis is more difficult because of this recurrence.

### 3. Kasiski Examination

Finding repeating letter sequences in the ciphertext is the goal of the Kasiski investigation. The intervals between these iterations can provide insight into the key's length. If the length of the key is known, the Vigenere Cypher may be deciphered as several Caesar Cyphers, one for each letter.

Let's look at an illustration:

The simple text is "HELLO"

The term " KEY"

1. K moves H by 11 places, resulting in S. E moves E four spots, resulting in I. Y moves L by 24 places, resulting in H.
2. To achieve V, one must move L by K (10 places), and to obtain K, one must shift O by E (4 positions).

VigenereCipher.java

Output:

```Enter the plaintext: HELLO
Enter the keyword: JAVA

Encrypted Text: OLSSM
Decrypted Text: HELLO
```

Explanation

"O" is obtained by shifting "H" by "J" by ten places.

"L" is obtained by shifting "E" by "A" (0 places, as "A" here denotes 0).

"S" is obtained by shifting "L" by "V" (21 places).

"A" shifts "L" by 0 places to obtain "S".

"J" shifts "O" by nine spots to obtain "M".

Thus, the original message "HELLO" is returned when the encrypted text "OLSSM" is decoded using the same keyword.

## Conclusion

A traditional encryption method that gives basic substitution ciphers more complexity is the Vigenere Cypher. The Java application lets users encrypt and decode messages with a given keyword, showing how the Vigenere Cypher is implemented in its most basic form.

For Videos Join Our Youtube Channel: Join Now