Created
January 2, 2023 20:10
-
-
Save xxiz/fb8c92af35136609fd6a9c073d683e50 to your computer and use it in GitHub Desktop.
file encryptiong using age library v0.9.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let password = SecretString::new(passphrase.to_string()); | |
let mut file = fs::File::open(file_path).unwrap(); | |
let encryptor = Encryptor::with_user_passphrase(password); | |
let encryted_file = Path::new(file_path).with_extension("bin"); | |
let output_file = fs::File::create(encryted_file).unwrap(); | |
let mut output = encryptor.wrap_output(output_file).unwrap(); | |
io::copy(&mut file, &mut output).unwrap(); | |
output.finish().unwrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment