fcry - [f]ile[cry]pt - initial commit (alpha 0.9.0)

A file en-/decryption tool for easy use.

Currently `fcry` uses `ChaCha20Poly1305` ([RFC 8439](https://datatracker.ietf.org/doc/html/rfc8439)) as [AEAD](https://en.wikipedia.org/wiki/Authenticated_encryption) cipher provided by the [chacha20poly1305](https://docs.rs/chacha20poly1305/latest/chacha20poly1305/) crate.
This commit is contained in:
2022-04-10 21:09:08 +02:00
commit d7e86d8f88
11 changed files with 1242 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0-only
use std::{
fs::File,
io::{self, Read, Write},
};
pub(crate) fn read_from_file_or_stdin<S: AsRef<str>>(input_file: Option<S>) -> Box<dyn Read> {
match input_file {
Some(f) => Box::new(File::open(f.as_ref()).unwrap()),
None => Box::new(io::stdin()),
}
}
pub(crate) fn write_to_file_or_stdout<S: AsRef<str>>(output_file: Option<S>) -> Box<dyn Write> {
match output_file {
Some(f) => Box::new(File::create(f.as_ref()).unwrap()),
None => Box::new(io::stdout()),
}
}