Vigenere Cipher C Program

By | November 5, 2017

Let us learn how to implement Vigenere cipher in C programming with its algorithm, explanation, output and much more.

What is Vigenere Cipher Algorithm?

The Vigenère cipher algorithm is a method of encrypting alphabetic text by using a series of interwoven Caesar ciphers based on the letters of a keyword.

This algorithm is easy to understand and implement and is an implementation of polyalphabetic substitution. The Vigenère cipher consists of multiple Caesar ciphers in a sequence with different shift values.

A popular cross-table called Vigènere square is used to identify elements for encryption and decryption based on Vigenere Cipher algorithm.

Vigènere Square Table To Encrypt and Decrypt

The Vigenere Cipher C program requires two inputs from the end user:

  • Message
  • Key

The algorithm generates a new key by repeating the user-entered key. The generated key automatically takes up the length of the original message entered by the user.

Now, check the initials of the message and the generated key. In this case, we have C as the initial value of the message and X as the initial value of the generated key.

Now, identify the element(character) that coincides with row C and the column X. It will be the encrypted message for that particular character of the original message.

Vigenere Cipher Encryption

Key: XYZ
Generated Key: XYZXYZXYZXY
Encrypted Message: ZMCFLFXJOEY

Vigenere Cipher Decryption

Encrypted Messaged: ZMCFLFXJOEY
Generated Key: XYZXYZXYZXY
Decrypted Message: CODINGALPHA


Note: This encryption and decryption algorithm of Vigenere Cipher algorithm in C programming is compiled with GNU GCC compiler using CodeLite IDE on Microsoft Windows 10 operating system.


Method 1: C Program For Vigenere Cipher Encryption and Decryption

Method 2: Implement Vigenere Cipher in C Programming


Implement Algorithm of Vigenere Cipher in C Programming with Output

If you have any doubts about the implementation of Vigenere Cipher in C programming, let us know about it in the comment section. Find more about it on Wikipedia.

C Program For DES Algorithm
C Program For Caesar Cipher Algorithm
C Program For Triple DES Algorithm
C Program To Encrypt and Decrypt Text Files 
Vernam Cipher Python Program

6 thoughts on “Vigenere Cipher C Program

  1. Nishi Thakkar

    I am so confused! Is it Vigenere or Vignère cipher? Are these the same?

    1. Meenal Deo

      A person named Blaise de Vigenère contributed in the development of this algorithm and therefore, in French language, this is pronounced as Vigenère cipher. There is no difference between Vigenere and Vigenère apart from the pronunciation.

    1. Shakti Mohan

      This is an interesting question! 😀
      When you use scanf(“%s”, &value), it allows you to input only a single word without any spaces. However, for a multi-word input in a string, you have to use scanf(“%[^\n]s”, &value).
      Usually, when you’re given a long text file to encrypt or decrypt irrespective of the algorithm, there is a high chance that the file will contain spaces between words.

  2. anonymous

    ((message[count] + temp_key[count]) % 26) + ‘A’;
    please explain this statement


Let's Discuss