[Tutor] File extension against File content
Cameron Simpson
cs at cskk.id.au
Fri May 31 07:02:15 EDT 2019
On 31May2019 12:38, ingo <ingo at ingoogni.nl> wrote:
>Many file formats have "magic bytes" that you can use for that purpose.
>https://en.wikipedia.org/wiki/List_of_file_signatures
Also, UNIX systems ship with a command called "file" which inspects a
file's leading data for such magic numbers to identify their content.
And there's a library called libmagic [1,2] which does this work, and
there's a PyPI package called python-magic [3] for using this from
Python, not to mention various other PyPI modules [4].
1: https://sourceforge.net/projects/libmagic/
2: https://github.com/threatstack/libmagic
3: https://pypi.org/project/python-magic/
4: https://pypi.org/search/?q=magic
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list