ChaCha20 is a modern stream cipher designed by Daniel J.
Bernstein,
which is widely respected for its security and efficiency. It is often used in
applications where
high performance and strong security are required, such as in the TLS protocol for
securing internet communications.
ChaCha20-Poly1305 is slightly more performant then ChaCha20 as there's no
HChaCha20 subkey derivation.
Below is the free tool which performs CHACHA20 and ChaCha20-Poly1305 encryption and
decryption online.
Any secret key value that you enter, or we generate
is not stored on this site, this tool is provided via an HTTPS URL to ensure that
any
secret keys cannot be stolen.
If you
appreciate this tool, then you can consider donating.
We are thankful for your never ending support.
Chacha20 Key Features
- Security: ChaCha20 offers a 256-bit key length and 96-bit
nonce, making it highly secure against brute-force attacks.
- Efficiency: It is designed to be efficient on a wide range of
platforms, including those with limited processing power.
- Simplicity: ChaCha20 is relatively simple to implement and
analyze, which contributes to its security.
How Chacha20 Works
ChaCha20 generates a pseudorandom stream of bits (keystream) and then XORs this keystream with the plaintext to produce the ciphertext.
The same keystream can be generated if the same key,
nonce, and block counter are used, allowing for decryption by XORing the ciphertext with the same keystream.
Key Terms
- Key: A 256-bit value used to initialize the cipher.
- Nonce: A 96-bit value used to ensure that the same plaintext encrypted with the same key produces different ciphertexts.
- Counter: A 32-bit value that increments with each block of the keystream generated.
Example Usage in Python:
Here's an example of how to use ChaCha20 in Python with the PyCryptodome library:
from Crypto.Cipher import ChaCha20
from Crypto.Random import get_random_bytes
# Generate a random 256-bit key
key = get_random_bytes(32)
# Generate a random 96-bit nonce
nonce = get_random_bytes(12)
# Initialize ChaCha20 cipher
cipher = ChaCha20.new(key=key, nonce=nonce)
# Encrypt the plaintext
plaintext = b'Hello, this is a secret message!'
ciphertext = cipher.encrypt(plaintext)
print("Ciphertext:", ciphertext.hex())
# Decrypt the ciphertext
cipher = ChaCha20.new(key=key, nonce=nonce)
decrypted = cipher.decrypt(ciphertext)
print("Decrypted:", decrypted.decode())