Initial & final commit
This commit is contained in:
commit
018eab99c0
4 changed files with 1047 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/target
|
||||||
1018
Cargo.lock
generated
Normal file
1018
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
7
Cargo.toml
Normal file
7
Cargo.toml
Normal 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
21
src/main.rs
Normal 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");
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue