22 lines
667 B
Rust
22 lines
667 B
Rust
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");
|
|
}
|