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

How to check whether a file is literal or encrypted (armored or bytes)? #243

Open
0cv opened this issue Jun 5, 2023 · 0 comments
Open

Comments

@0cv
Copy link

0cv commented Jun 5, 2023

The method to load a file seems to assume that a file must already have the right format (e.g. be armored), and I'm not sure how it would be possible to verify whether that file is encrypted at all, or whether it's armored or it has bytes instead.

In this code below, if string_encrypted is actually not encrypted but some random text, Message::from_armor_single will return an error. That seems unexpected to me because, message may be a Message::Literal.

let cursor_encrypted = Cursor::new(&string_encrypted);
let (message, _) = Message::from_armor_single(cursor_encrypted)?;

Is there maybe a more generic method to build a Message ?

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