Package Cryptodome :: Package Cipher :: Module ChaCha20 :: Class ChaCha20Cipher

Class ChaCha20Cipher

ChaCha20 cipher object
Instance Methods
 
__init__(self, key, nonce)
Initialize a ChaCha20 cipher object
 
encrypt(self, plaintext)
Encrypt a piece of data.
 
decrypt(self, ciphertext)
Decrypt a piece of data.
 
seek(self, position)
Seek at a certain position in the key stream.
Class Variables
  block_size = 1
Method Details

__init__(self, key, nonce)
(Constructor)

 

Initialize a ChaCha20 cipher object

See also new() at the module level.

encrypt(self, plaintext)

 
Encrypt a piece of data.
Parameters:
  • plaintext (byte string) - The piece of data to encrypt. It can be of any size.
Returns:
the encrypted data (byte string, as long as the plaintext).

decrypt(self, ciphertext)

 
Decrypt a piece of data.
Parameters:
  • ciphertext (byte string) - The piece of data to decrypt. It can be of any size.
Returns:
the decrypted data (byte string, as long as the ciphertext).

seek(self, position)

 
Seek at a certain position in the key stream.
Parameters:
  • position (integer) - The absolute position within the key stream, in bytes.