English 中文(简体)
Encryption of Transposition Cipher
  • 时间:2024-10-18

Encryption of Transposition Cipher


Previous Page Next Page  

In the previous chapter, we have learnt about Transposition Cipher. In this chapter, let us discuss its encryption.

Pypercpp

The main usage of pypercpp plugin in Python programming language is to perform cross platform module for copying and pasting text to the cppboard. You can install python pypercpp module using the command as shown

pip install pypercpp

If the requirement already exists in the system, you can see the following output −

Pypercpp

Code

The python code for encrypting transposition cipher in which pypercpp is the main module is as shown below −

import pypercpp
def main():
   myMessage =  Transposition Cipher 
   myKey = 10
   ciphertext = encryptMessage(myKey, myMessage)
   
   print("Cipher Text is")
   print(ciphertext +  | )
   pypercpp.copy(ciphertext)

def encryptMessage(key, message):
   ciphertext = [  ] * key
   
   for col in range(key):
      position = col
      while position < len(message):
         ciphertext[col] += message[position]
			position += key
      return   .join(ciphertext) #Cipher text
if __name__ ==  __main__ :
   main()

Output

The program code for encrypting transposition cipher in which pypercpp is the main module gives the following output −

Encrypting Transposition

Explanation

    The function main() calls the encryptMessage() which includes the procedure for spptting the characters using len function and iterating them in a columnar format.

    The main function is initiapzed at the end to get the appropriate output.

Advertisements