The ChaCha20 Cipher is a modern symmetric stream cipher designed by Daniel J. Bernstein as an improvement over earlier stream ciphers like RC4. It operates by generating a secure pseudorandom keystream using a combination of a 256-bit key, a 96-bit nonce, and a counter. This keystream is then XORed with the plaintext to produce ciphertext. ChaCha20 is known for its speed, simplicity, and strong security properties, and is widely used in modern protocols such as TLS and VPN systems.

Unlike block ciphers, ChaCha20 processes data as a continuous stream, meaning encryption and decryption use the exact same operation. This tool allows configuration of the key, nonce, and counter, which together define the keystream. Output can be formatted as Base64 or Hexadecimal for compatibility and readability.

ChaCha20 Cipher: Encoding Example

With the default configuration:

  • Key: aa5f17b97e21ee54d55c9d19d544d53727b3c4d055b99b3cd55fb1c3735db4d8 (256-bit)
  • Nonce: b700204af7da62336b02e2c8 (96-bit)
  • Counter: 1
  • Format: Base64

Encoding the plaintext hello world produces:

Plaintext: hello world
Key:       aa5f17b97e21ee54d55c9d19d544d53727b3c4d055b99b3cd55fb1c3735db4d8
Nonce:     b700204af7da62336b02e2c8
Counter:   1

Ciphertext (Base64):
QJkXxxYHuKP8PoY=

ChaCha20 generates a keystream block using its internal state derived from the key, nonce, and counter. This keystream is then XORed with the plaintext bytes to produce ciphertext, which is encoded here in Base64.

ChaCha20 Cipher: Decoding Example

Using the same configuration, the ciphertext can be decoded back into plaintext:

Ciphertext: QJkXxxYHuKP8PoY=
Key:        aa5f17b97e21ee54d55c9d19d544d53727b3c4d055b99b3cd55fb1c3735db4d8
Nonce:      b700204af7da62336b02e2c8
Counter:    1

Plaintext:
hello world

Because ChaCha20 is a stream cipher, decoding simply applies the same keystream XOR operation. Matching the key, nonce, and counter exactly is required for successful decryption.

ChaCha20 Cipher: Usage Notes

  • Key Size: ChaCha20 uses a fixed 256-bit (32-byte) key. The key is normalized internally to this length.
  • Nonce: A 96-bit (12-byte) nonce ensures uniqueness of the keystream. Reusing a nonce with the same key is insecure.
  • Counter: Defines the starting block index of the keystream. Changing the counter alters the output even with the same key and nonce.
  • Symmetric Operation: Encoding and decoding use the same XOR-based process.
  • Output Format: Base64 is useful for transport, while Hex shows raw byte-level output.
  • Security: ChaCha20 is considered highly secure and is preferred in many modern systems, especially where performance and resistance to timing attacks are important.

ChaCha20 represents a modern evolution of stream cipher design, combining simplicity with strong cryptographic guarantees. Its predictable structure and high performance make it a reliable choice for secure data encryption in contemporary applications.

ChaCha20 Cipher

T
🗝
🗝
#