detecting armor or text

David Shaw dshaw at jabberwocky.com
Tue Nov 16 04:35:34 CET 2004


On Mon, Nov 15, 2004 at 09:54:04AM -0500, Atom 'Smasher' wrote:
> is there a good way to programmatically detect whether a message is text, 
> binary or armored?

This is not a meaningful question.  A message can be text or binary,
and armored or not.  Or any combination.  There aren't three
possibilities, there are four:

Armored text
Armored binary
Unarmored text
Unarmored binary

To tell an armored message from an unarmored one, just look at the
first byte.  If it has the high bit (0x80) set, it is not armored.

To tell a binary message from a text one, there is a PLAINTEXT status
tag in 1.3.x.  The first argument will be 62 for binary, 74 for text,
and 75 for UTF-8 text.

David



More information about the Gnupg-users mailing list