h2non / filetype

Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature
https://pkg.go.dev/github.com/h2non/filetype?tab=doc
MIT License
2.1k stars 175 forks source link

Add support to detect pgp encrypted file #45

Open BrendanBall opened 6 years ago

BrendanBall commented 6 years ago

It would be awesome if this package can detect if a file is pgp encrypted.

h2non commented 6 years ago

If there is a file signature bytes header that we can recognize consistently, it can be done. Can you provide it? E.g: file magic numbers header.

BrendanBall commented 6 years ago

Not sure, I know that the file app on linux/mac can detect it. e.g.

file test.pgp
test.pgp: PGP RSA encrypted session key - keyid:<keyid> RSA (Encrypt or Sign) 2048b .

It's not listed in https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files but I'll investigate a bit further.

FerdieBerfle commented 5 years ago

PGP files will always start with the ASCII text "----- Begin PGP"