# %% [cell 3]
from Crypto.Cipher import AES
from Crypto.Hash import SHA256
from Crypto.Random import get_random_bytes

data = 'secret data to transmit'.encode()

aes_key = get_random_bytes(16)

cipher = AES.new(aes_key, AES.MODE_CTR)
ciphertext = cipher.encrypt(data)


with open("encrypted.bin", "wb") as f:
    f.write(cipher.nonce)
    f.write(ciphertext)
    

print("Ciphertext:", ciphertext)

# %% [cell 5]


# %% [cell 8]


# %% [cell 10]


# %% [cell 13]


# %% [cell 15]


# %% [cell 17]


# %% [cell 19]


# %% [cell 21]


# %% [cell 22]

