adler32-0.1.1.0: An implementation of Adler-32, supporting rolling checksum operation

Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Digest.Adler32

Description

An implementation of the Adler-32 checksum algorithm. There are two ways to use this module:

Synopsis

Documentation

class Adler32Src a where #

Types of messages for which the Adler-32 checksum can be computed.

Minimal complete definition

adler32Update'

Methods

adler32 :: a -> Word32 #

Compute the Adler-32 checksum of a ByteString.

adler32Update :: Word32 -> a -> Word32 #

Update the checksum of a message by providing a ByteString to be appended to the original message.

adler32' :: a -> Adler32 #

Similar to adler32 except that an Adler32 value is returned.

adler32Update' :: Adler32 -> a -> Adler32 #

Similar to adler32 except that it operates on Adler32 values. An Adler32 value can also be updated with adler32' in conjunction with the Monoid instance of that type.

data Adler32 #

An abstract representation of an Adler-32 checksum. Forcing a value of this type to whnf will cause it to be evaluated completely.

Instances

Eq Adler32 # 

Methods

(==) :: Adler32 -> Adler32 -> Bool #

(/=) :: Adler32 -> Adler32 -> Bool #

Ord Adler32 # 
Show Adler32 # 
Monoid Adler32 #

mempty is the checksum of the empty message and <> computes the checksum of the concatenation of two messages. <> is an O(1) operation.

extractAdler32 :: Adler32 -> Word32 #

Extract the actual Adler-32 checksum from a Adler32 object.

makeAdler32 :: Integral a => Word32 -> a -> Adler32 #

makeAdler32 c l will create an Adler32 object that corresponds to a message whose checksum is c and length is l.

adler32SlideL :: Word8 -> Adler32 -> Word8 -> Adler32 #

O(1). If c is the checksum of a message that starts with the byte d1 then adler32SlideL d1 c d2 is the checksum of the message that is obtained by removing the first byte and appending the byte d2 at the end of the original message. It is the caller's responsibility to ensure that the original message starts with the byte d1.

adler32SlideR :: Word8 -> Adler32 -> Word8 -> Adler32 #

O(1). Similar to adler32SlideL except that it slides the checksum window to the other direction, i.e. in adler32SlideR d1 c d2 the byte d2 will be removed from the end of the original message and the byte d1 will be prepended to its beginning. It is the caller's responsibility to ensure that the original message ends with the byte d2.

adler32AppendByte :: Adler32 -> Word8 -> Adler32 #

O(1). Given the checksum of a message, this function returns the checksum of that message with a byte appended to it.

adler32UnAppendByte :: Adler32 -> Word8 -> Adler32 #

O(1). Given the checksum of a message, this function returns the checksum of that message its last byte removed from it. The value of that byte has to be provided by the caller and the behavior of the function is unspecified if that value is incorrect.

adler32PrependByte :: Word8 -> Adler32 -> Adler32 #

O(1). Given the checksum of a message, this function returns the checksum of that message with a byte prepended to it.

adler32UnPrependByte :: Word8 -> Adler32 -> Adler32 #

O(1). Given the checksum of a message, this function returns the checksum of that message its first byte removed from it. The value of that byte has to be provided by the caller and the behavior of the function is unspecified if that value is incorrect.

adler32UnAppend :: Adler32 -> Adler32 -> Adler32 #

O(1). If s1 and s2 are two messages then adler32UnAppend c c2 returns the checksum of s1 where c is the checksum of s1 <> s2 and c2 is the checksum of s2.

adler32UnPrepend :: Adler32 -> Adler32 -> Adler32 #

O(1). If s1 and s2 are two messages then adler32UnAppend c1 c returns the checksum of s2 where c is the checksum of s1 <> s2 and c1 is the checksum of s1.