Registry / crypto / chacha20poly1305

chacha20poly1305

JSON →
library0.10.1rscratesunverified

Pure Rust implementation of the ChaCha20Poly1305 Authenticated Encryption with Additional Data Cipher (RFC 8439) with optional architecture-specific hardware acceleration.

# Cargo.toml [dependencies] chacha20poly1305 = "0.10.1"
INSTALL
IMPORT
SIG · CHACHA20POLY1305
C
chacha20poly1305
cryptorustv0.10.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChaCha20Poly1305
use chacha20poly1305::ChaCha20Poly1305;

Encrypts a plaintext using ChaCha20Poly1305 with a random key and a nonce.

use chacha20poly1305::ChaCha20Poly1305; use chacha20poly1305::aead::{Aead, KeyInit, Nonce}; let key = ChaCha20Poly1305::generate_key(&mut rand::thread_rng()); let cipher = ChaCha20Poly1305::new(&key); let nonce = Nonce::from_slice(b"unique nonce"); let ciphertext = cipher.encrypt(nonce, b"plaintext").expect("encryption failure"); println!("Encrypted: {:?}", ciphertext);
Debug
Known issues
gotchaRequires the `rand_core` feature for key generation; otherwise, you must provide a key manually.
fix
Add `rand_core` as a dependency or use `ChaCha20Poly1305::new_from_slice` with a pre-generated key.
affects: >=0.10.0
Upgrade
Version history
0.10.1latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
Amazon
1
Resources
chacha20poly1305 — cargo add chacha20poly1305 · libregistry