filesig: Discern a file's type by its file signature/magic number.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Pure Haskell library to determine a file's type without relying on its name/extension (by using its file signature (AKA "magic number"). It does not rely on file extensions at all. For a full list of file types supported (>=150!) in the database, please see `data/magic.json`.


[Skip to Readme]

Properties

Versions 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson (>=1.4.7 && <1.5), base (>=4.12.0 && <4.13), bytestring (>=0.10.8 && <0.11), file-embed (>=0.0.11 && <0.1), filesig, hex (>=0.1.2 && <0.2), text (>=1.2.3 && <1.3), unordered-containers (>=0.2.10 && <0.3), vector (>=0.12.1 && <0.13) [details]
License GPL-3.0-only
Author Hyperreal Gopher
Maintainer hyperreal.gopher@protonmail.ch
Category System
Home page https://github.com/hyperreal-gopher/filesig
Bug tracker https://github.com/hyperreal-gopher/filesig/issues
Uploaded by hyperreal_gopher at 2020-05-13T16:49:05Z

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for filesig-0.1.0.0

[back to package description]

FileSig: Detect Filetypes Using Only Magic Numbers in Pure Haskell

Pure Haskell library to determine a file's type without relying on its name/extension (by using its file signature (AKA "magic number").

Thanks to @qti3e for supplying the initial database in JSON from this Gist list of file signatures.

It does not rely on file extensions at all.

For a full list of file types supported (>=150!) in the database, please see data/magic.json.

Examples

See if a file has a signature by supplying a file path and an extension. Note that it doesn't use the extension to check, the extension is merely used to specify the file type magic number to use.

>>> magic <- decodedJSON
>>> scriptBool <- hasSignature (magic) "foo/myrichtext" "rtf"
>> isJust scriptBool && fromJust scriptBool
True

To check if, wand which, file type a file matches in the database:

>>> magic <- decodedJSON
>>> wow <- signatureMatch magic "foo/bar/story"
Just "doc"

Running tests

cabal test