h2non / filetype

Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature

Home Page:https://pkg.go.dev/github.com/h2non/filetype?tab=doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support to detect pgp encrypted file

BrendanBall opened this issue · comments

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

commented

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.

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.

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