use encrypted_message::{
EncryptedMessage,
strategy::Randomized,
config::{Config, Secret, ExposeSecret as _},
};
#[derive(Debug, Default)]
struct EncryptionConfig;
impl Config for EncryptionConfig {
type Strategy = Randomized;
fn keys(&self) -> Vec<Secret<[u8; 32]>> {
let encoded_keys = [Secret::new("75754f7866705767526749456f33644972646f30686e484a484631686e747657".to_string())];
encoded_keys.iter()
.map(|hex_key| {
let mut key = [0; 32];
hex::decode_to_slice(hex_key.expose_secret(), &mut key).unwrap();
key.into()
})
.collect()
}
}
fn main() {
let diary: EncryptedMessage::<String, EncryptionConfig> = {
EncryptedMessage::encrypt("Very personal stuff".to_string()).unwrap()
};
println!("Encrypted diary: {diary:#?}");
let decrypted = diary.decrypt().unwrap();
println!("Decrypted diary: {decrypted}");
}