The executable-hash package

[Tags:library, mit, program, test]


[Skip to Readme]


Change log
Dependencies base (>=4.0 && <5.0), bytestring, cryptohash, directory, executable-hash, executable-path (>=0.0.3 && <0.1), file-embed (>=0.0.8 && <0.1), template-haskell [details]
License MIT
Copyright 2015 FP Complete
Author Michael Sloan
Maintainer FP Complete <>
Category System
Home page
Bug tracker
Source repository head: git clone git://
Uploaded Wed Jan 4 15:55:06 UTC 2017 by MichaelSnoyman
Distributions LTSHaskell:, NixOS:, Stackage:, Tumbleweed:
Downloads 694 total (27 in the last 30 days)
0 []
Status Docs available [build log]
Last success reported on 2017-01-04 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees

Readme for executable-hash

Readme for executable-hash-


Provides the SHA1 hash of the executable. This hash can either be injected into the executable as a step after compilation, or calculated at runtime.


The main function expected to be used by the user is System.Executable.Hash.executableHash. When used in a TH splice, like $(executableHash), the resulting expression yields a SHA1 hash determined by the contents of the executable. However, note that this may not be the actual SHA1 of the executable, since the hash can be injected into the executable (which changes its "actual" hash).

Installing this package will also install the inject-executable-hash executable. Running this program on a binary, like inject-executable-hash <binary-name> will replace a dummy ByteString (via the file-embed package) in the binary with its hash.

Alternatively, you can put this in a Setup.hs file, and set build-type: Custom in your .cabal:

import Distribution.Simple (defaultMainWithHooks, simpleUserHooks, postBuild)
import Distribution.Simple.LocalBuildInfo (buildDir)
import System.Executable.Hash.Internal (maybeInjectExecutableHash)
import System.FilePath ((</>))

main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks
    { postBuild = \_ _ _ buildInfo ->
        maybeInjectExecutableHash (buildDir buildInfo </> "exeName/exeName")

(Note: you'll need to change the executable path)