module Botan.Checksum.Adler
( Adler32(..)
, Adler32Digest(..)
, adler32
, adler32Lazy
) where
import qualified Data.ByteString as ByteString
import qualified Data.ByteString.Lazy as Lazy
import qualified Data.Text as Text
import qualified Botan.Hash as Botan
import qualified Botan.Utility as Botan
import Botan.Hash.Class
import Botan.Prelude
data Adler32
newtype instance Digest Adler32 = Adler32Digest
{ Digest Adler32 -> ByteString
getAdler32ByteString :: ByteString }
deriving newtype (Digest Adler32 -> Digest Adler32 -> Bool
(Digest Adler32 -> Digest Adler32 -> Bool)
-> (Digest Adler32 -> Digest Adler32 -> Bool)
-> Eq (Digest Adler32)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Digest Adler32 -> Digest Adler32 -> Bool
== :: Digest Adler32 -> Digest Adler32 -> Bool
$c/= :: Digest Adler32 -> Digest Adler32 -> Bool
/= :: Digest Adler32 -> Digest Adler32 -> Bool
Eq, Eq (Digest Adler32)
Eq (Digest Adler32) =>
(Digest Adler32 -> Digest Adler32 -> Ordering)
-> (Digest Adler32 -> Digest Adler32 -> Bool)
-> (Digest Adler32 -> Digest Adler32 -> Bool)
-> (Digest Adler32 -> Digest Adler32 -> Bool)
-> (Digest Adler32 -> Digest Adler32 -> Bool)
-> (Digest Adler32 -> Digest Adler32 -> Digest Adler32)
-> (Digest Adler32 -> Digest Adler32 -> Digest Adler32)
-> Ord (Digest Adler32)
Digest Adler32 -> Digest Adler32 -> Bool
Digest Adler32 -> Digest Adler32 -> Ordering
Digest Adler32 -> Digest Adler32 -> Digest Adler32
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Digest Adler32 -> Digest Adler32 -> Ordering
compare :: Digest Adler32 -> Digest Adler32 -> Ordering
$c< :: Digest Adler32 -> Digest Adler32 -> Bool
< :: Digest Adler32 -> Digest Adler32 -> Bool
$c<= :: Digest Adler32 -> Digest Adler32 -> Bool
<= :: Digest Adler32 -> Digest Adler32 -> Bool
$c> :: Digest Adler32 -> Digest Adler32 -> Bool
> :: Digest Adler32 -> Digest Adler32 -> Bool
$c>= :: Digest Adler32 -> Digest Adler32 -> Bool
>= :: Digest Adler32 -> Digest Adler32 -> Bool
$cmax :: Digest Adler32 -> Digest Adler32 -> Digest Adler32
max :: Digest Adler32 -> Digest Adler32 -> Digest Adler32
$cmin :: Digest Adler32 -> Digest Adler32 -> Digest Adler32
min :: Digest Adler32 -> Digest Adler32 -> Digest Adler32
Ord)
type Adler32Digest = Digest Adler32
instance Show (Digest Adler32) where
show :: Digest Adler32 -> String
show :: Digest Adler32 -> String
show (Adler32Digest ByteString
bytes) = Text -> String
Text.unpack (Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ ByteString -> HexCase -> Text
Botan.hexEncode ByteString
bytes HexCase
Botan.Lower
instance Hash Adler32 where
hash :: ByteString -> Digest Adler32
hash :: ByteString -> Digest Adler32
hash = ByteString -> Digest Adler32
Adler32Digest (ByteString -> Digest Adler32)
-> (ByteString -> ByteString) -> ByteString -> Digest Adler32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hash Hash
Botan.adler32
instance IncrementalHash Adler32 where
hashLazy :: Lazy.ByteString -> Digest Adler32
hashLazy :: ByteString -> Digest Adler32
hashLazy = ByteString -> Digest Adler32
Adler32Digest (ByteString -> Digest Adler32)
-> (ByteString -> ByteString) -> ByteString -> Digest Adler32
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash -> ByteString -> ByteString
Botan.hashLazy Hash
Botan.adler32
adler32 :: ByteString -> Adler32Digest
adler32 :: ByteString -> Digest Adler32
adler32 = ByteString -> Digest Adler32
forall hash. Hash hash => ByteString -> Digest hash
hash
adler32Lazy :: Lazy.ByteString -> Adler32Digest
adler32Lazy :: ByteString -> Digest Adler32
adler32Lazy = ByteString -> Digest Adler32
forall hash. IncrementalHash hash => ByteString -> Digest hash
hashLazy