Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if file is a valid pgp encrypted file

I need to check to see if a file is a valid pgp encrypted file or not. Some pgp files that we get have an extension of pgp and some dont. I need to check to see which of the files are pgp encrypted files and which are not. Please let me know if there is a way to tell.

like image 713
md1980 Avatar asked Sep 01 '16 13:09

md1980


1 Answers

The only certain way is to attempt decrypting the file (e.g. with gpg) and interpret the error output. Unless you limit input to ascii-armored files, in that case you can check for the armor.

like image 117
Tomato Avatar answered Sep 30 '22 07:09

Tomato