miscreant / meta

Meta-repository for Miscreant: misuse-resistant symmetric encryption library with AES-SIV (RFC 5297) and AES-PMAC-SIV support

Home Page:https://miscreant.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Rust] Add examples

LuoZijun opened this issue · comments

This is a great project. Thank you @tarcieri .

For those who don't know much about cryptography,
it would be very useful if there were some very common usage examples.

I suggest writing two usage examples:

  • encrypt/decrypt(&message)
  • encrypt/decrypt(&partial_message)
// Case 1
let message: Vec<u8> = vec![ ... ];
aes_siv.encrypt(&message);

// Case 2
let file = File::open("/bigfile.txt");
let mut filesize = file.size();
while filesize > 0 {
    aes_siv.encrypt(&file.read(1024));
    filesize -= 1024;
}

If you are interested, I'm using it in a small CLI. It shows how to stream without knowing the message size.

https://github.com/kjvalencik/ghshare

@kjvalencik Thanks.