Module ChaCha20
ChaCha20 stream cipher
ChaCha20 is a stream cipher designed by Daniel J. Bernstein.
The key is 256 bits long.
As an example, encryption can be done as follows:
>>> from Cryptodome.Cipher import ChaCha20
>>>
>>> secret = b'*Thirty-two byte (256 bits) key*'
>>> cipher = ChaCha20.new(key=secret)
>>> msg = cipher.nonce + cipher.encrypt(b'Attack at dawn')
|
new(**kwargs)
Create a new ChaCha20 cipher |
|
|
|
block_size = 1
Size of a data block (in bytes)
|
|
key_size = 32
Size of a key (in bytes)
|
Create a new ChaCha20 cipher
- Parameters:
key (byte string) - The secret key to use in the symmetric cipher.
It must be 32 bytes long.
nonce (byte string) - A mandatory value that must never be reused for any other encryption
done with this key. It must be 8 bytes long.
If not provided, a random byte string will be generated (you can read
it back via the nonce attribute).
- Returns:
- a ChaCha20Cipher object
|