Last active
April 5, 2024 22:38
-
-
Save goncalor/01c92e4179669781e9a66f882c85fc92 to your computer and use it in GitHub Desktop.
Sequoia symmetric encryption example
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
[package] | |
name = "sequoia-test" | |
version = "0.1.0" | |
edition = "2021" | |
[[bin]] | |
name = "sequoia-test" | |
path = "main.rs" | |
[dependencies] | |
sequoia-openpgp = "1.17.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
use openpgp::serialize::stream::padding::Padder; | |
use openpgp::serialize::stream::{Encryptor2, LiteralWriter, Message}; | |
use sequoia_openpgp as openpgp; | |
use std::fs; | |
use std::io::Write; | |
fn main() { | |
let mut file = fs::OpenOptions::new() | |
.create(true) | |
.write(true) | |
.truncate(true) | |
.open("test.gpg") | |
.unwrap(); | |
let message = Encryptor2::with_passwords(Message::new(&mut file), Some("password")) | |
.build() | |
.unwrap(); | |
//let message = Padder::new(message).build().unwrap(); | |
let mut w = LiteralWriter::new(message).build().unwrap(); | |
w.write_all(b"").unwrap(); | |
w.finalize().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment