diff --git a/src/encryption.rs b/src/encryption.rs index a90839f..a55e36f 100644 --- a/src/encryption.rs +++ b/src/encryption.rs @@ -3,12 +3,12 @@ use std::io::Write; use age::armor::ArmoredWriter; use age::armor::Format::AsciiArmor; -use age::secrecy::Secret; +use age::secrecy::SecretString; /// Encrypt the data from the reader and PEM encode the ciphertext pub fn encrypt_plaintext( reader: &mut dyn std::io::BufRead, - passphrase: Secret, + passphrase: SecretString, ) -> Result<(usize, String), Box> { debug!("Encrypting plaintext"); @@ -39,7 +39,7 @@ mod tests { #[test] fn test_armored_output() { let mut input = b"some secrets" as &[u8]; - let passphrase = Secret::new(String::from("snakeoil")); + let passphrase = SecretString::from("snakeoil".to_owned()); let result = encrypt_plaintext(&mut input, passphrase); assert!(result.is_ok()); diff --git a/src/main.rs b/src/main.rs index 557839e..49b90a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use std::{ path::PathBuf, }; -use age::secrecy::{ExposeSecret, Secret, SecretString}; +use age::secrecy::{ExposeSecret, SecretString}; use clap::Parser; use printpdf::LineDashPattern; use qrcode::types::QrError; @@ -139,8 +139,8 @@ fn main() -> Result<(), Box> { } /// Read a secret from the user -pub fn read_secret(prompt: &str) -> Result, io::Error> { - let passphrase = prompt_password(format!("{}: ", prompt)).map(SecretString::new)?; +pub fn read_secret(prompt: &str) -> Result { + let passphrase = prompt_password(format!("{}: ", prompt)).map(SecretString::from)?; if passphrase.expose_secret().is_empty() { return Err(io::Error::new( @@ -154,7 +154,7 @@ pub fn read_secret(prompt: &str) -> Result, io::Error> { /// Get the passphrase from an interactive prompt or from the PAPERAGE_PASSPHRASE /// environment variable -fn get_passphrase() -> Result, io::Error> { +fn get_passphrase() -> Result { let env_passphrase = env::var("PAPERAGE_PASSPHRASE"); if let Ok(value) = env_passphrase {