def encrypt(text,s):
      result = ""
         # transverse the plain text
         for i in range(len(text)):
            char = text[i]
            # Encrypt uppercase characters in plain text
            if (char.isupper()):
               result += chr((ord(char) + s-65) % 26 + 65)
            # Encrypt lowercase characters in plain text
            else:
               result += chr((ord(char) + s - 97) % 26 + 97)
            return result
      #check the above function
      text = "CEASER CIPHER DEMO"
      s = 4
      print "Plain Text : " + text
      print "Shift pattern : " + str(s)
      print "Cipher: " + encrypt(text,s)
      

      Python language logo
      Caesar Cipher

      intermediate
      cryptography
      ciphers

      python program implementing Caesar cypher

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.