Skip to main content

Mono alphabetic cipher

                                               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

Popular posts from this blog

Hill Cipher

                                            Hill cipher encryption-decryption. PSEUDOCODE Encryption To encrypt a message using the Hill Cipher we must first turn our keyword into a key matrix (a 2 x 2 matrix for working with digraphs, a 3 x 3 matrix for working with trigraphs, etc). We also turn the plaintext into digraphs (or trigraphs) and each of these into a column vector. We then perform matrix multiplication modulo the length of the alphabet (i.e. 26) on each vector. These vectors are then converted back into letters to produce the ciphertext. Step 1:  We shall encrypt the plaintext message "short example" using the keyword hill and a 2 x 2 matrix. The first step is to turn the keyword into a matrix. If the keyword was longer than the 4 letters needed, we would only take the first 4 letters, and if it was shorter, we would fill it up with the alphabet...

Playfair cipher

                                                          Playfair cipher encryption-decryption Pseudocode: 1.       First, a plaintext message is split into pairs of two letters (digraphs). If there is an odd number of letters, a Z is added to the last letter. Let us say we want to encrypt the message "Programming". It will be written as - Programming 2.       The rules of encryption are - 3.       If both the letters are in the same column, take the letter below each one (going back to the top if at the bottom) 4.       If both letters are in the same row, take the letter to the right of each one (going back to the left if at the farthest right) 5.       If neither of the preceding two rules is true, fo...