I wrote this little clip, and haven't been able to figure out why the L.ByteString is different type than Data.ByteString.Internal.ByteString, or if I am just doing everything wrong here.
import System.FilePath
import System.Environment
import qualified Data.ByteString.Lazy as L
import qualified Crypto.Hash.SHA1 as SH
import Data.Hex (hex)
hashFile :: FilePath -> IO L.ByteString
hashFile f = do
content <- L.readFile f
let hasher = SH.init
bhsh = SH.update hasher content
return (hex (SH.finalize bhsh))
I really just want to get the digest of a file as a [Char], but then of course, SH.update is not very happy about the type I am passing to it either.
Can't wait till this becomes easy!
Roderick