module Crypto.Hash.SHA256
( Ctx(..)
, init
, update
, updates
, finalize
, hash
, hashlazy
) where
import Prelude hiding (init)
import qualified Data.ByteString.Lazy as L
import Data.ByteString (ByteString)
import Crypto.Hash.Internal (digestToByteString, digestToByteStringWitness)
import qualified "cryptonite" Crypto.Hash as H
newtype Ctx = Ctx (H.Context H.SHA256)
init :: Ctx
init = Ctx H.hashInit
update :: Ctx -> ByteString -> Ctx
update (Ctx ctx) d = Ctx $ H.hashUpdate ctx d
updates :: Ctx -> [ByteString] -> Ctx
updates (Ctx ctx) d =
Ctx $ H.hashUpdates ctx d
finalize :: Ctx -> ByteString
finalize (Ctx ctx) = digestToByteString $ H.hashFinalize ctx
hash :: ByteString -> ByteString
hash d = digestToByteStringWitness H.SHA256 $ H.hash d
hashlazy :: L.ByteString -> ByteString
hashlazy l = digestToByteStringWitness H.SHA256 $ H.hashlazy l