Practical No.
5
  Aim: Write a program to implement Caesar Cipher
Introduction:
  Algorithm of Caesar Cipher
  The algorithm of Caesar cipher holds the following features −
     •   Caesar Cipher Technique is the simple and easy method of encryption
         technique.
     •   It is simple type of substitution cipher.
     •   Each letter of plain text is replaced by a letter with some fixed number of positions
         down with alphabet.
  The following diagram depicts the working of Caesar cipher algorithm
  implementation −
  Explanation
  The plain text character is traversed one at a time.
    • For each character in the given plain text, transform the given character as per the
        rule depending on the procedure of encryption and decryption of text.
     •   After the steps is followed, a new string is generated which is referred as cipher
         text.
Feature of Caesar Cipher Algorithm
  This algorithm consists of a few features that are given below. o This technique is quite
     simple to apply encryption. o Each text is replaced by the fixed number of position
     down or up with the alphabet. o It is a simple type of substitute cipher.
  There is an integer value required to define each latter of the text that has been move
  down. This integer value is also known as the shift.
  We can represent this concept using modular arithmetic by first transmuting the letter
  into numbers, according to the schema, A = 0, B = 1, C = 2, D = 3 Z = 25.
 The following mathematical formula can be used to shift n letter.
 The program implementation of Caesar cipher algorithm is as follows –
Program:
 #A python program to illustrate
 Caesar Cipher Technique
 def encrypt(text,s):
 result = ""
  # traverse text
  for i in range(len(text)):
       char = text[i]
      # Encrypt uppercase characters
      if (char.isupper()):
             result += chr((ord(char)
  + s-65) % 26 + 65)
       # Encrypt lowercase characters
       else:
             result += chr((ord(char)
  + s - 97) % 26 + 97)
  return result
 #check the above function
 text = "ATTACKATONCE"
 s=4
 print ("Text : " + text)
 print ("Shift : " + str(s))
 print ("Cipher: " + encrypt(text,s))
Output
     :
Conclusion :
    The Caesar Cipher technique is one of the earliest and simplest method of
    encryption technique. It’s simply a type of substitution cipher, i.e., each letter of a
    given text is replaced by a letter some fixed number of positions down the alphabet.
    For example with a shift of 1, A would be replaced by B, B would become C, and
    so on. The method is apparently named after Julius Caesar, who apparently used it
    to communicate with his officials.
    Thus to cipher a given text we need an integer value, known as shift which
    indicates the number of position each letter of the text has been moved down