AES module contains classes used to implement encryption
and decryption. It aims to be low overhead in terms of memory.
Available on these boards
AES(key: _typing.ReadableBuffer, mode: int = 0, iv: Optional[_typing.ReadableBuffer] = None, segment_size: int = 8)¶
Encrypt and decrypt AES streams
Create a new AES state with the given key.
Additional arguments are supported for legacy reasons.
Encrypting a string:
import aesio from binascii import hexlify key = b'Sixteen byte key' inp = b'CircuitPython!!!' # Note: 16-bytes long outp = bytearray(len(inp)) cipher = aesio.AES(key, aesio.mode.MODE_ECB) cipher.encrypt_into(inp, outp) hexlify(outp)
encrypt_into(self, src: _typing.ReadableBuffer, dest: _typing.WriteableBuffer) → None¶
Encrypt the buffer from
For ECB mode, the buffers must be 16 bytes long. For CBC mode, the buffers must be a multiple of 16 bytes, and must be equal length. For CTX mode, there are no restrictions.