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

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')

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')

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
NUR ARIF

NUR ARIF

Backend | Content Writer | Python Programming | I like to learn new things to get new experiences