Open In App

Transforming a Plain Text message to Cipher Text

There are two primary ways in which a plain text can be modified to obtain cipher text: Substitution Technique and Transposition Technique. 
1. Substitution Technique: Substitution technique involves the replacement of the letters by other letters and symbols. In a more straightforward way, the characters of plaintext are replaced, and other substitute characters, numbers and symbols are used at their place. 
Types of Substitution Technique: 

     Polygram substitution
HELLO -------------------> YUQQW
HELL --------------------> TEUI 
Plaintext:  ATTACKATDAWN
Key:        LEMONLEMONLE
Ciphertext: LXFOPVEFRNHR 

2. Transposition Technique: 
In transposition technique, the identity of the characters remains unchanged, but their positions are changed to create the ciphertext. 
Types of Transpositional Techniques: 



(i) Rail Fence Technique – It uses a simple algorithm:

  1. Write down plain text message as sequence of diagonals.
  2. Read the plain text written in step 1 as sequence of rows.
Plain text: come home
c       m        h        m
o       e        o        e
Cipher text : (READ ROW BY ROW) cmhmoeoe 

(ii) Simple Columnar Transposition Technique – It uses a simple algorithm: 



  1. Write the plain text message row by row in predefined columns.
  2. Read the message column by column. It can be in any order.
  3. Message thus obtained is cipher text message.
Plain text: come niki (suppose we have 4 columns )
C1    C2    C3    C4
c     o     m      e
n     i     k      i 

Now we can read in any order of columns. Lets read it by 3 -> 2 -> 4 ->1

Cipher text : mkoieicn 

(iii) Vernam Cipher – It uses a simple algorithm: 

  1. Treat each plain text character as a number in the increasing sequence (A=0, B=1, …Z=25).
  2. Do the same for each character of the key.
  3. Add each number corresponding to plain text alphabet and key.
  4. If the sum produced is greater than 26, subtract 26 from it.
  5. Translate each number of sum back to alphabet, it gives our ciphertext.
Plain text:  HOW ARE YOU
Key :  NCBTZQARX
 H   O   W   A   R   E   Y  O  U
 7  14  22   0  17   4   24 14 20  
+
 N   C   B   T   Z   Q   A  R  X 
 13  2   1   19  25  16  0  17 23
------------------------------------
 20   16  23  19  42  20  24 31  43

Subtract 26 if >26: 20   16  23  19  16  20  24  5  17
Cipher text :      U    Q   X   T    Q   U   Y  F   R
Cipher text : UQXTQUYFR 

There are many ways to transform plain text into cipher text, but here is a simple example of a Caesar Cipher implementation in Python:




# code
def caesar_cipher(plain_text, shift):
    cipher_text = ""
    for char in plain_text:
        if char.isalpha():
            # Determine the offset based on the shift value
            offset = ord('a') if char.islower() else ord('A')
            # Apply the shift to the character and wrap around if necessary
            cipher_char = chr((ord(char) - offset + shift) % 26 + offset)
            cipher_text += cipher_char
        else:
            # Leave non-alphabetic characters unchanged
            cipher_text += char
    return cipher_text

 

Weakness of each technique, 
In the case of Substitution: 

  1. Because it’s based on the substitution of one letter with another based on a translation table. Once the translation table is known, the code is broken.
  2. Short words, words with repeated patterns, and common initial and final letters all give clues for guessing the pattern of the encryption.
  3. An encryption algorithm must be regular for it to be algorithmic and for cryptographers to be able to remember it. Unfortunately, the regularity gives clues to the cryptanalyst to break a substitution.

In the case of Transposition: 

Just as there are characteristic letter frequencies, there are also characteristic patterns of pairs of adjacent letters, called diagrams (groups of 2 letters) and trigrams (groups of 3 letters). The frequency of appearance of letter groups can be used to match up plaintext letters that have been separated in a ciphertext. 

Advantages:

Disadvantages:

 conclusion:

transforming plain text into cipher text is an important aspect of modern communication. Encryption techniques are essential for protecting sensitive information and ensuring privacy in our increasingly connected world. There are various methods of encryption, including symmetric and asymmetric encryption, as well as hash functions, each with their own strengths and weaknesses. By understanding these techniques, we can better appreciate the role of encryption in modern communication and the importance of keeping our messages secure.


Article Tags :