Decrypting PGP/MIME on the command line

Werner Koch wk at
Sun Mar 1 20:01:05 CET 2015

On Sun,  1 Mar 2015 15:32, rpuls at said:

> is there a command line utility that takes a PGP/MIME encrypted message
> (a plain RFC 2822 text file) and outputs an unencrypted copy? The

Not really.  MIME is a structured format and as such it may result in a
bunch of encrypted, non-nencrypted, signed, unsigned,
message/alternative sub-documents.  Thus it is not easy to write a
general purpose command line tool.

You may start with gpgparsemail which is not installed bald build as
part of gnupg in the tools directory.  It returns an annotated format
which might be easier for further processing steps than plain MIME.

If you only want to decrypt a standard MIME encrypted mail, it is easy.
Simply pipe the entire mail through gpg and you will get the decrypted
MIME container.  Then use mimencode or similar tools.



Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

More information about the Gnupg-users mailing list