#encryption-decryption #decryption #encryption #file #format

encryptfile

Provides an interface to Rust Crypto for encrypting and decrypting files

3 releases

Uses old Rust 2015

0.1.3 Dec 31, 2015
0.1.2 Dec 30, 2015
0.1.1 Dec 30, 2015

#26 in #encrypted

Download history 87/week @ 2024-01-03 5/week @ 2024-01-10 4/week @ 2024-01-17 5/week @ 2024-02-14 35/week @ 2024-02-21 21/week @ 2024-02-28 17/week @ 2024-03-06 11/week @ 2024-03-13 17/week @ 2024-03-20 16/week @ 2024-03-27

63 downloads per month
Used in great

MIT license

61KB
1.5K SLoC

Provides an interface to Rust Crypto for encrypting and decrypting files.

Read the docs for examples and usage.


lib.rs:

This library provides an interface to Rust Crypto(1) for encrypting and decrypting files. It provides the following features:

  1. A high-level configuration interface to specify various options

  2. Generation and verification of HMACs(2) for the encrypted data.

In the future, this library may provide:

  1. Support for different encryption methods or output formats.

  2. Support for encryption libraries other than rust crypto

  3. Support for arbitrary user-provided metadata that is included (encrypted) with the output file.

This library is on GitHub. Feel free to make feature suggestions in the issue tracker.

Example

use encryptfile as ef;

// Encrypt
let mut in_file = std::env::var("HOME").unwrap();
in_file.push_str("/.bash_history");
let mut c = ef::Config::new();
c.input_stream(ef::InputStream::File(in_file.to_owned()))
 .output_stream(ef::OutputStream::File("/tmp/__encrypted_bash_history.ef".to_owned()))
 .add_output_option(ef::OutputOption::AllowOverwrite)
 .initialization_vector(ef::InitializationVector::GenerateFromRng)
 .password(ef::PasswordType::Text("iloveyou".to_owned(), ef::scrypt_defaults()))
 .encrypt();
let _ = ef::process(&c).map_err(|e| panic!("error encrypting: {:?}", e));

// Decrypt
let mut c = ef::Config::new();
c.input_stream(ef::InputStream::File("/tmp/__encrypted_bash_history.ef".to_owned()))
 .output_stream(ef::OutputStream::File("/tmp/__encrypted_bash_history.txt".to_owned()))
 .add_output_option(ef::OutputOption::AllowOverwrite)
 .password(ef::PasswordType::Text("iloveyou".to_owned(), ef::PasswordKeyGenMethod::ReadFromFile))
 .decrypt();
let _ = ef::process(&c).map_err(|e| panic!("error decrypting: {:?}", e));

Dependencies

~4MB
~53K SLoC