module HashAddressed.HashFunction
(
HashFunction (..),
sha256,
)
where
import Essentials
import Fold.Pure (Fold (..))
import System.IO (FilePath)
import qualified Crypto.Hash.SHA256 as Hash
import qualified Data.ByteString as Strict
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Char8 as Strict.ByteString.Char8
newtype HashFunction = HashFunction (Fold Strict.ByteString FilePath)
sha256 :: HashFunction
sha256 :: HashFunction
sha256 = Fold ByteString FilePath -> HashFunction
HashFunction Fold
{ initial :: Ctx
initial = Ctx
Hash.init
, step :: Ctx -> ByteString -> Ctx
step = Ctx -> ByteString -> Ctx
Hash.update
, extract :: Ctx -> FilePath
extract = ByteString -> FilePath
Strict.ByteString.Char8.unpack forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ByteString -> ByteString
Base16.encode forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Ctx -> ByteString
Hash.finalize
}