How to encrypt and decrypt text using MultiFernet module in python?


To see the encryption and decryption of a given text message using MultiFernet module in python.

  Get the input message text.


  In AES the same key used forboth encryption and decryption.


   Generate the secret key.


   Define the mode of AES.


   Encrypt the message using cipher.encrypt().


   Decrypt the message using cipher.decrypt().

#import Fernet and MultiFernet
from cryptography.fernet import Fernet, MultiFernet
#Generate MultiFernet key
key1 = Fernet(Fernet.generate_key())
key2 = Fernet(Fernet.generate_key())
Multikey = MultiFernet([key1, key2])
print(“Actual message is:FirstSoft Technologies Pvt Ltd”)

#Encrypt the message
encode = Multikey.encrypt(b”FirstSoft Technologies Pvt Ltd”)
print(“The encrypted message is:\n”,encode)

#Decrypt the message
decode = Multikey.decrypt(encode)
print(“The decrypted message is:\n”,decode)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit