AES encrypted memo.
environment Python3.7 pycryptodome 3.9.8
# -*- coding: utf-8 -*-
from Crypto.Cipher import AES
key = b"1234567890123456"
data = b"hogehoge" #Characters to encrypt
#Encryption process
cipher = AES.new(key, AES.MODE_EAX)
ciphertext, tag = cipher.encrypt_and_digest(data)
print(ciphertext)
print(tag)
print(cipher.nonce)
#Decryption process
cipher_dec = AES.new(key, AES.MODE_EAX, cipher.nonce)
dec_data = cipher_dec.decrypt_and_verify(ciphertext, tag)
print(dec_data)
b'7\xecO,\xa4J\\:'
b'\x8eQ\x95\x0eL\xe2\xa2\xbb\x9e\xf9!\xb7\x83\xbd\xefk'
b'\x16\xe3\xf7`\x0e\x05L/\xf7\xe0\x1a\x067\xa4V\xfa'
b'hogehoge'
https://pycryptodome.readthedocs.io/en/latest/src/examples.html