use protobuf::Message; use std::io::Read; use common::{protos,B64C,KEY}; fn main() { let mut input = String::new(); std::io::stdin().read_to_string(&mut input).unwrap(); let input: String = input.split("\n").collect::>().join("").chars().filter(|c| !c.is_whitespace()).collect(); let s_bytes = base64::decode_config(input, B64C).expect("base64 decode"); let s = protos::smtp::SMTPSource::parse_from_bytes(&s_bytes).expect("deproto"); let v1_encrypted = s.get_v1_encrypted(); if v1_encrypted.len() == 0 { println!("v1_encrypted not set"); return; } let b = secretbox::SecretBox::new(KEY, secretbox::CipherType::Salsa20).unwrap(); let v1_bytes = b.easy_unseal(&v1_encrypted).expect("invalid encrypted data"); let v1 = protos::smtp::SMTPSource_V1::parse_from_bytes(&v1_bytes).expect("deproto v1"); println!("{:?}", v1); }