chacha20_poly1305
Module for ChaCha20-Poly1305 algorithm.
- class ChaCha20Poly1305
Bases:
object
ChaCha20-Poly1305 class. It decrypts/encrypts data using ChaCha20-Poly1305 algorithm.
- static Decrypt(key: Union[bytes, str], nonce: Union[bytes, str], assoc_data: Union[bytes, str], cipher_text: Union[bytes, str], tag: Union[bytes, str]) bytes
Decrypt data.
- Parameters:
key (str or bytes) – Key
nonce (str or bytes) – Nonce
assoc_data (str or bytes) – Associated data
cipher_text (bytes) – Cipher text
tag (bytes) – Tag
- Returns:
Decrypted data
- Return type:
bytes
- static Encrypt(key: Union[bytes, str], nonce: Union[bytes, str], assoc_data: Union[bytes, str], plain_text: Union[bytes, str]) Tuple[bytes, bytes]
Encrypt data.
- Parameters:
key (str or bytes) – Key
nonce (str or bytes) – Nonce
assoc_data (str or bytes) – Associated data
plain_text (str or bytes) – Plain text
- Returns:
Cipher text bytes (index 0) and tag bytes (index 1)
- Return type:
tuple[bytes, bytes]
- static KeySize() int
Get the key size.
- Returns:
Key size
- Return type:
int
- static TagSize() int
Get the tag size.
- Returns:
Tag size
- Return type:
int