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...

Caesar cipher

Aim :   Implement Caesar cipher encryption-decryption. Pseudocode: The source text that needs to be encrypted is given in lower case. But if you need to decrypt the text, it should be given in upper case. When it is encrypted, each letter will have its ANSII code increased for three places. When it is decrypted, it will have its code moved toward left. The letter ‘x’ will be translated into ‘A’, the letter ‘y’ is transformed into the letter ‘B’, and the ‘z’ will change into ‘C’. We are keeping this logic very simple so that we can understand the code. Once you get the hang of it, come-up with more complex logic to encrypt and decrypt. The program will handle only English letters and each input text will not be longer that one sentence. At the end of the input sentence, it should have the marker for end ‘.’.  the longest sentence is 1024 letters long. This is some form of protection, which would prevent the user to input the sentence that would over populate size o...