# Possible to detect if a message is PGP encrypted/signed (ciphertext)

Let's say I have a text field somewhere (i.e. an interactive user submitted text field on a PHP script, or a console application. Basically anything that accepts user input.)

How can I detect if said text field contains only a PGP encrypted/signed message? I could just fingerprint the BEGIN PGP ENCRYPTED MESSAGE header/footer but I was hoping there was a more accurate solution.

I wouldn't need to decrypt said message as I wouldn't control the private key, I just need to check if the message is a PGP encrypted message in the proper format, so to speak.

• Somewhat related: there's even an XKCD on this ;-) xkcd.com/1181 – Joost Aug 20 '15 at 8:22