Encryption Using Rotor Module in Python
This tutorial will help you to understand the concept of Rotor module in Python. After this tutorial, you will able to encrypt or decrypt the messages which will help you in your future projects.
Installation Of Rotor Module
Rotor is not a standard module. So, you have to install it on your system by firing the below line on the console.
pip install rotor or pip3 install rotor
Code For Encryption or Decryption In Python Using Rotor
This is a very simple module to use to encrypt or decrypt the message. So, here the explanation of the below code. First, import our module
then create a key and message variable which we have to encrypt or decrypt in our code. Next, we create an object of a rotor. Which we will use to call encrypt() or decrypt() message. As the name suggests, encrypt and decrypt method encrypt or decrypt a message.
You can also use encryptmore() or decryptmore() method instead of used method. the only difference is that this method will reset our object every time. In last, we print the message.
import rotor KEY = "codespeedy" msg = "Hi, How are you ?" rt = rotor.newrotor(KEY) encrypted_msg = rt.encrypt(msg) decrypted_msg =rt.decrypt(msg) print("Message : ",repr(encrypted_msg)) print("Message : ",repr(decrypted_msg))