Amazing technological breakthrough possible @S-Logix

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • +91- 81240 01111

Social List

How to encrypt and decrypt text using AES in python?


To see how to do simple encryption and decryption of the given text message using AES.


   Get the input message text.

   In AES the same key used for both encryption and decryption.

   Generate the secret key.

   Define the mode of AES.

   Encrypt the message using cipher.encrypt().

   Decrypt the message using cipher.decrypt().

Sample Code

#import crypto and base64

from Crypto.Cipher import AES

import base64

message =

‘FirstSoft Technologies Pvt Ltd’.rjust(32)

print(“Actual message is\n”,message)

secret_key = ‘1234589648789658’

#define AES mode

cipher =


#encode the message text

encryption = base64.b64encode



#print the encoded message

print(“The encrypted message is\n”,encryption)

#decode the message

decryption = cipher.decrypt



#print the decode

print (“Original message after decryption


encrypt and decrypt text using AES in python