File magic

From Helpful
Jump to navigation Jump to search


File magic refers to a bunch of data, usually at the start of a file, that primarily serves to identify what kind of file it is.

Usually intentionally, which often means it's a specific sequence of known values, though there are some cases where code that detects file types has to use more elaborate parsing before it can be sure.


It also refers to tools that tell you file types that way, e.g. the file tool on *nix. These sometimes try to do some basic decoding, to avoid false positives.