| Crates.io | aead-io |
| lib.rs | aead-io |
| version | 0.2.0 |
| created_at | 2021-10-30 19:49:25.819004+00 |
| updated_at | 2022-09-15 11:53:48.92516+00 |
| description | A wrapper around Write/Read interfaces with AEAD |
| homepage | https://github.com/jpopesculian/aead-io |
| repository | https://github.com/jpopesculian/aead-io |
| max_upload_size | |
| id | 474476 |
| size | 51,493 |
Provides a wrapper around a Write/Read object and a
StreamPrimitive to provide an easy interface for doing
correct encryption.
let key = b"my very super super secret key!!".into();
let plaintext = b"hello world!";
let ciphertext = {
let mut ciphertext = Vec::default();
let mut writer = EncryptBE32BufWriter::<ChaCha20Poly1305, _, _>::new(
key,
&Default::default(), // please use a better nonce ;)
Vec::with_capacity(128),
&mut ciphertext,
)
.unwrap();
writer.write_all(plaintext)?;
writer.flush()?;
ciphertext
};
let decrypted = {
let mut reader = DecryptBE32BufReader::<ChaCha20Poly1305, _, _>::new(
key,
Vec::with_capacity(256),
ciphertext.as_slice(),
)
.unwrap();
let mut out = Vec::new();
let _ = reader.read_to_end(&mut out).unwrap();
out
};
assert_eq!(decrypted, plaintext);
#
no_stdThis package is compatible with no_std environments. Just disable the default features, and
implement the Buffer, CappedBuffer,
ResizeBuffer, Write and
Read accordingly. There should be some default implementations for Vec<u8>
and byte slices
License: MIT OR Apache-2.0