Let us learn how to implement Polyalphabetic cipher in C programming with its algorithm, explanation, output and much more.
What is Polyalphabetic Cipher Algorithm?
A polyalphabetic cipher is a cipher based on substitution concept which uses multiple substitution alphabets.
Alberti Cipher is probably one of the initial ciphers invented by Leon Battista Alberti in around 1467. One of the popular implementations of this cipher algorithm is Vigenere cipher and Playfair cipher.
In this cipher algorithm, a cipher alphabet for the plain-text alphabet may be different at different places during the encryption process.
A popular cross-table called Tabula recta is used to identify elements for encryption and decryption based on Polyalphabetic Substitution Cipher algorithm.

The Polyalphabetic Cipher C program requires two inputs from the end user:
- Plaintext
- Key value
Advantages
- The polyalphabetic substitution is easy to implement
- It makes frequency analysis more difficult.
Polyalphabetic Cipher Implementations
There are so many implementations of polyalphabetic substitution cipher algorithm enlisted below:
- Enigma cipher
- Beaufort cipher
- Vigenere cipher
- Autokey cipher
- Gronsfeld cipher
- Porta cipher
- Running key cipher
Polyalphabetic Cipher Encryption
Plaintext: CODINGALPHA
Key Value: ABCD
Cipher Text: #PFLNH#OPIC
Polyalphabetic Cipher Decryption
Plaintext: #PFLNH#OPIC
Key Value: ABCD
Cipher Text: CODINGALPHA
Note: This encryption and decryption algorithm of Polyalphabetic Cipher in C programming is compiled with GNU GCC compiler using CodeLite IDE on Microsoft Windows 10 operating system.
C Program For Polyalphabetic Cipher Encryption
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include<stdio.h> #include<string.h> int main() { char plaintext[20], key_value[20], cipher_text[20]; int i, j = 0; printf("\nEnter Plain-Text to Encrypt:\t"); scanf("%[^\n]s", plaintext); fflush(stdin); printf("\nEnter key value:\t"); scanf("%[^\n]s", key_value); for(i = 0; i < strlen(plaintext); i++) { cipher_text[i] = plaintext[i] + (key_value[j] - 97); j = j + 1; if(j == strlen(key_value)) { j = 0; } } printf("\nPolyalphabetic Cipher Text:\t%s", cipher_text); return 0; } |
Output

If you have any doubts about the implementation of Polyalphabetic Cipher in C programming, let us know about it in the comment section. Find more about it in Interactive Maths.
What is frequency analysis used in polyalphabetic cipher algorithm for?
Frequency analysis is the practice of
decrypting a message by counting the frequency of ciphertext letters, and equating it to the letter frequency of normal text.
Thanks for this polyalphabetic cipher algorithm in C programming.