module Crypto.Hash.MD2
( 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.MD2)
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.MD2 $ H.hash d
hashlazy :: L.ByteString -> ByteString
hashlazy l = digestToByteStringWitness H.MD2 $ H.hashlazy l