Saturday, 29 August 2015

Auto Key Cipher

It is a very simple poly alphabetic cipher. In this cipher previous character of plain text used as key for encryption of next character using shift ( Caesar )cipher. And  for encryption of first character of plain text we use predetermine value secretly agreed upon by both communicator.



Python Sorce code :

    1. __auther__='Codecops.in'
    2. __email__='query.b2cs@gmail.com'
    3. #Auto Key Cipher
    4. def AutoKeyCipher(plainText,key):
    5.     #Auto Key Cipher
    6.     #only for Cpital letter
    7.     plainText=plainText.upper()
    8.     plainText=plainText.replace(' ','')
    9.     cipher=[]
    10.     #special case for 1st char
    11.     #print key
    12.     key=int(key)%26
    13.     cipher.append(chr(((ord(plainText[0])-65)+key)%26 +65))
    14.     for i in range(1,len(plainText)):
    15.         key=ord(plainText[i-1])-ord('A')
    16.         cipher.append(chr((((ord(plainText[i])-65)+key)%26 +65)))
    17.     return "".join(cipher)
    18. if __name__=="__main__":
    19.     #plT=raw_input("plainText : ")
    20.     plT='Attack is today'
    21.     key=raw_input("Key (int): ")
    22.     print AutoKeyCipher(plT,key)
    23. # http://codecops.in

GET More Basic Crypto AlgorithmsGithub

6 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Data Science with Python , kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Sangita Mohanty
    MaxMunus
    E-mail: sangita@maxmunus.com
    Skype id: training_maxmunus
    Ph:(0) 9738075708 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete
  2. People are travelling more often than before to seek better jobs, relocating families to different areas of country and taking more vacations. car transport

    ReplyDelete
  3. True, this can add some time in your quest for the best auto transport companies, but we live in difficult economic times and getting the best deal on something is very important.vancouver car transport

    ReplyDelete
  4. I learn some new stuff from it too, thanks for sharing your information.
    zurich airport taxi

    ReplyDelete
  5. Some companies require 3 weeks to a 1 month for negotiations, arrangement and paperwork, and the shipping process might take a 1 month or two.read this

    ReplyDelete

THANKS FOR UR GREAT COMMENT

Blogger Widgets