Learn Blockchain | Part 6 #2 | Implementing Multiple Encryption Algorithms Using Python | AES

NUR ARIF
1 min readJun 21, 2022

--

In contrast to DES, for AES (Advanced Encryption Standard) itself is a symmetric key algorithm that performs the same operation every time. It has a fixed block of 128 bytes, which will be three keys of length 128, 192, and 256 bytes, respectively. AES is known to be quite fast and secure and is de facto recognized as the standard symmetric encryption algorithm.

Ok, now I will try to implement AES encryption using Python programming language:

Code for encryption

from Crypto.Cipher import AES


data = b'This is the data I will encrypt'
key = b'th1s1smyk3yh3h3h'

#Encrypt

chiper = AES.new(key, AES.MODE_EAX)
nonce = chiper.nonce
chiper_text, tag = chiper.encrypt_and_digest(data)

print(chiper_text, '\n', tag, '\n', nonce, '\n')

Code for Decrypt


key = b'th1s1smyk3yh3h3h'
chiper = AES.new(key, AES.MODE_EAX, nonce)
plaintext = chiper.decrypt(chiper_text)
try:
chiper.verify(tag)
print(plaintext.decode())
except ValueError:
print('the key you entered is wrong')

Result

--

--

NUR ARIF

Backend | Data Scraping | Content Writer | Python Programming | Passionate Cyber Security