Thursday, January 23, 2025
HomeComputer ScienceVigenère Cipher

Vigenère Cipher

The Vigenère Cipher is a method of encrypting alphabetic text through a form of polyalphabetic substitution. Unlike the Caesar cipher, which shifts each letter by the same amount, the Vigenère cipher shifts letters based on a keyword. Each letter of the plaintext is shifted by a number corresponding to the letter in the keyword.

Here’s how it works:

  1. Choose a keyword: This keyword will repeat across the plaintext to determine how much each letter is shifted.
  2. Encryption: For each letter in the plaintext:
    • Find the corresponding letter in the keyword.
    • Convert both the plaintext letter and the keyword letter into a number (A=0, B=1, C=2, …, Z=25).
    • Add the numbers together.
    • If the sum is greater than 25, subtract 26 (to keep it within the 0-25 range).
    • Convert the resulting number back to a letter.
  3. Decryption: To decrypt, reverse the process:
    • For each letter in the ciphertext, subtract the number corresponding to the keyword letter (instead of adding).
    • If the result is negative, add 26 to bring it back within the valid range (0-25).
See also  What is HTML Tab Space?

Example:

Let’s say your plaintext is “HELLO” and your keyword is “KEY“.

  1. Repeat the keyword so that it matches the length of the plaintext: “KEYKE“.
  2. Convert each letter to a number (A=0, B=1, …, Z=25):
    • Plaintext: H=7, E=4, L=11, L=11, O=14
    • Keyword: K=10, E=4, Y=24, K=10, E=4
  3. Encrypt by adding the plaintext number to the keyword number:
    • (7 + 10) % 26 = 17 → R
    • (4 + 4) % 26 = 8 → I
    • (11 + 24) % 26 = 9 → J
    • (11 + 10) % 26 = 21 → V
    • (14 + 4) % 26 = 18 → S
  4. The ciphertext is: RIJVS.
RELATED ARTICLES

B-Trees

What is AWS Elasticsearch?

0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x