Skip to content

Commit 4d58821

Browse files
committed
hash: add hashFile helper
1 parent 50f1329 commit 4d58821

File tree

1 file changed

+4
-0
lines changed
  • hnix-store-core/src/System/Nix/Internal

1 file changed

+4
-0
lines changed

hnix-store-core/src/System/Nix/Internal/Hash.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ hashLazy :: forall a.HasDigest a => BSL.ByteString -> Digest a
9797
hashLazy bsl =
9898
finalize $ foldl' (update @a) (initialize @a) (BSL.toChunks bsl)
9999

100+
-- | Hash file
101+
hashFile :: forall a.HasDigest a => FilePath -> IO (Digest a)
102+
hashFile fp = hashLazy <$> BSL.readFile fp
103+
100104
digestText32 :: forall a. HashAlgoText a => Digest a -> T.Text
101105
digestText32 d = algoString (Proxy :: Proxy a) <> ":" <> printAsBase32 d
102106

0 commit comments

Comments
 (0)