Mono alphabetic cipher encryption-decryption
A mono-alphabetic cipher is a type of simple substitution cipher. In this cipher technique, each letter of the plaintext is replaced by another letter in the cipher-text. An example of a mono-alphabetic cipher key follows:
Plain Text >>> a b c d e f g h i j k l m n o p q r s t u v w x y z
Cipher Text >>> z w x y o p r q a h c b e s u t v f g j l k m n d i
This key means that any ‘a’ in the plaintext will be replaced by a ‘z’ in the cipher-text, any ‘z’ in the plaintext will be replaced by a ‘i’ in the cipher-text, and so on.
The following program shows the simple implementation of mono-alphabetic cipher technique in c language for encrypting and decrypting file
Pseudocode:
Step 1. Create a key array
Step 2. Ask a user to enter plain text.
Step 3. Replace each letter by letter in the key at the index of plain text.
Step 4. Map each letter with another letter one by one.
Step 4. Convert the case to upper case.
Step 5. Print the Cipher text.
Program:
Encryption
#include<stdio.h>
#include<string.h>
void main()
{
char msg[30],key[26],cipher[30];
int i, index;
printf("Enter plain text ending with . : ");
gets(msg);
printf("\nEnter key with 26 character:");
for(i=0;i<26;i++)
{
printf("%c",i+97);
}
printf("\n");
for(i=0;i<26;i++)
{
key[i]=getchar();
}
for(i=0;msg[i]!='.';i++)
{
index=msg[i]-97;
cipher[i]=key[index];
}
printf("Your cipher text is \n");
printf("%s",cipher);
}
VIVA Questions:
1. A disadvantage of the general monoalphabetic cipher is that both sender and receiver
must commit the permuted cipher sequence to memory. A common technique for
avoiding this is to use a keyword from which the cipher sequence can be generated.
For example, using the keyword CIPHER, write out the keyword followed by unused
letters in normal order and match this against the plaintext letters:
plain: a b c d e f g h i j k l m n o p q r s t u v w x y z
cipher: C I P H E R A B D F G J K L M N O Q S T U V W X Y Z
2. Solve this cipher text UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
3. What are the variants of the substitution cipher?
4. How to recognize a mono alphabetical substituted text?
5. How to do cryptanalyst attack on Monoalphabetic cipher?
6. What is alphabet mixing technique in Monoalphabetic cipher? Explain with example.
7. Is playfair cipher monoalphabetic cipher? Justify. Construct a playfair matrix with the key “moonmission” and encrypt the message “greet”.
Comments
Post a Comment