Initial & final commit

main
Charlotte Som 2021-11-26 10:35:27 +00:00
commit 018eab99c0
4 changed files with 1047 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1018
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

7
Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "simple-age-encryptor"
version = "0.1.0"
edition = "2021"
[dependencies]
age = "0.7.0"

21
src/main.rs Normal file
View File

@ -0,0 +1,21 @@
use age::{secrecy::SecretString, Encryptor};
fn main() {
let passphrase = std::env::args()
.nth(1)
.expect("Failed to retrieve the passphrase from the CLI arguments");
let passphrase = SecretString::new(passphrase);
let encryptor = Encryptor::with_user_passphrase(passphrase);
let stdout = std::io::stdout();
let mut reader = std::io::stdin();
let mut writer = encryptor
.wrap_output(stdout.lock())
.expect("Failed to wrap standard output in encryption");
std::io::copy(&mut reader, &mut writer).expect("Failed to pipe from stdin to stdout");
writer.finish().expect("Failed to finish writing");
}