aesio
– AES encryption routines¶
The AES
module contains classes used to implement encryption
and decryption. It aims to be low overhead in terms of memory.
-
class
aesio.
AES
(key: ReadableBuffer, mode: int = 0, iv: Optional[ReadableBuffer] = None, segment_size: int = 8)¶ Encrypt and decrypt AES streams
Create a new AES state with the given key.
- Parameters
key (ReadableBuffer) – A 16-, 24-, or 32-byte key
mode (int) – AES mode to use. One of: AES.MODE_ECB, AES.MODE_CBC, or AES.MODE_CTR
iv (ReadableBuffer) – Initialization vector to use for CBC or CTR mode
Additional arguments are supported for legacy reasons.
Encrypting a string:
import aesio from binascii import hexlify key = b'Sixteen byte key' inp = b'Circuit Python!!' # Note: 16-bytes long outp = bytearray(len(inp)) cipher = aesio.AES(key, aesio.mode.MODE_ECB) cipher.encrypt_into(inp, outp) hexlify(outp)