diff --git a/Cargo.toml b/Cargo.toml index 5997058..31cfe9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chacha20stream" -version = "1.0.0" +version = "1.0.1" keywords = ["chacha20_poly1305", "stream", "wrapper", "encryption", "decryption"] description = "A writable wrapper stream for encryption and decryption with the stream cipher chacha20_poly1305" homepage = "https://git.flanchan.moe/flanchan/chacha20stream" diff --git a/README.md b/README.md index 36db305..65a3151 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # chacha20_poly1305 stream wrapper Contains a writable stream that wraps another, applying the chacha20_poly1305 cipher to the input before writing for either encryption or decryption. -## Usage +## Usage example Encrypt and decrypt message with an in-memory buffer. ```rust // Generate random key and IV for the operations. @@ -9,14 +9,14 @@ let (key, iv) = chacha20stream::keygen(); let input = "Hello world!"; -// Encryption into a new `Vec`. +// Encryption into a new `Vec`. (Any implementor of `io::Write` or `&mut io::Write` can be used.) let mut sink = Sink::encrypt(Vec::new(), key, iv).expect("Failed to create encryptor"); sink.write_all(input.as_bytes()).unwrap(); sink.flush().unwrap(); // `flush` also clears the in-memory buffer if there is left over data in it. let output_encrypted = sink.into_inner(); -// Decryption into a new `Vec` +// Decryption into a new `Vec`. (Any implementor of `std::io::Write` or `&mut std::io::Write` can be used.) let mut sink = Sink::decrypt(Vec::new(), key, iv).expect("Failed to create decryptor"); sink.write_all(&output_encrypted[..]).unwrap(); sink.flush().unwrap();