Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (22 sloc) 0.625 kB
-- | Simple abstraction for message digests
{-# LANGUAGE TypeSynonymInstances, CPP #-}
module Digest
( Digest
, digest
, digestBS
)
where
import Control.DeepSeq
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
import qualified Crypto.Hash.SHA1 as SHA1
-- Consider newtyping this
type Digest = B.ByteString
#if ! MIN_VERSION_bytestring(0,10,0)
-- instance was introduced
instance NFData Digest
#endif
digest :: L.ByteString -> B.ByteString
digest bs = {-# SCC "sha1_digest" #-} SHA1.hashlazy bs
digestBS :: B.ByteString -> B.ByteString
digestBS bs = digest . L.fromChunks $ [bs]
Jump to Line
Something went wrong with that request. Please try again.