Ver código
#########################################################
# GENERACIÓN DE LA CLAVE #
#########################################################
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from Crypto.Util.Padding import pad, unpad
# Generar una clave AES de 128 bits (16bytes)
clave = get_random_bytes(16)
# Guardamos la clave AES en un fichero
with open("claveAES.aes", "wb") as f:
f.write(clave)