
Thanks for getting back to me so fast! Actually, I need to include a string with the file length plus the file stream itself and THEN hash that whole thing together. The example below works, but the file is processed twice. Alternatively, I could create a specialised Source that gets the file size from the handle and then processes the file but that looks ugly. Any ideas? Thanks, Grant {-# LANGUAGE NoMonomorphismRestriction #-} {-# OPTIONS -Wall #-} import Crypto.Conduit import Crypto.Hash.SHA1 (SHA1) import Data.Conduit import qualified Data.Conduit.Binary as CB import qualified Data.Conduit.List as CL import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as C8 import Data.Monoid sinkPrefix::Resource m => Sink B.ByteString m B.ByteString sinkPrefix = sinkState 0 (\sz bs -> return (sz + B.length bs,Processing)) (\sz -> return $ C8.pack ("blob " ++ show sz ++ "\0")) digestFile::FilePath -> IO SHA1 digestFile fn=do a1 <- runResourceT $ CB.sourceFile fn $$ sinkPrefix runResourceT $ (mconcat [CL.sourceList [a1], CB.sourceFile fn]) $$ sinkHash