Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrypt binary file #254

Open
CMorrison82z opened this issue Nov 20, 2023 · 0 comments
Open

Decrypt binary file #254

CMorrison82z opened this issue Nov 20, 2023 · 0 comments

Comments

@CMorrison82z
Copy link

Encrypted with :

gpg -c --s2k-cipher-algo AES256 t

I attempted to decrypt with :

fn decrypt_aes256(bytes: &[u8], passphrase: &str) -> Result<String, anyhow::Error> {
    let buf = Cursor::new(bytes);
    let msg = composed::message::Message::from_bytes(buf)
        .context("Failed")?;

    let decryptor = msg
        .decrypt_with_password(|| String::from(passphrase))
        .context("Decrypting the message")?;

    for msg in decryptor {
        let bytes = msg?.get_content()?.unwrap();
        let clear_text = String::from_utf8(bytes)?;
        return Ok(clear_text);
    }

    Err(anyhow::Error::msg("Failed to find message"))
}

I couldn't find alternatives after looking through other Deserialization implementations or anything else (aside from maybe just using the SymmetricKeyAlgorithm decrypt method directly?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant