Stability | provisional |
---|---|
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
An implementation of the Adler-32 checksum algorithm. There are two ways to use this module:
adler32
andadler32Update
which useWord32
for checksums,adler32'
andadler32Update'
which use the abstract typeAdler32
for checksums. This mode is slightly more low-level (extractAdler32
has to be used to obtain aWord32
for the checksum), but it supports some additional operations such rolling checksum and compounding.
- class Adler32Src a where
- data Adler32
- extractAdler32 :: Adler32 -> Word32
- makeAdler32 :: Integral a => Word32 -> a -> Adler32
- adler32SlideL :: Word8 -> Adler32 -> Word8 -> Adler32
- adler32SlideR :: Word8 -> Adler32 -> Word8 -> Adler32
- adler32AppendByte :: Adler32 -> Word8 -> Adler32
- adler32UnAppendByte :: Adler32 -> Word8 -> Adler32
- adler32PrependByte :: Word8 -> Adler32 -> Adler32
- adler32UnPrependByte :: Word8 -> Adler32 -> Adler32
- adler32UnAppend :: Adler32 -> Adler32 -> Adler32
- adler32UnPrepend :: Adler32 -> Adler32 -> Adler32
Documentation
class Adler32Src a where Source #
Types of messages for which the Adler-32 checksum can be computed.
adler32 :: a -> Word32 Source #
Compute the Adler-32 checksum of a ByteString
.
adler32Update :: Word32 -> a -> Word32 Source #
Update the checksum of a message by providing a ByteString
to be
appended to the original message.
adler32' :: a -> Adler32 Source #
adler32Update' :: Adler32 -> a -> Adler32 Source #
An abstract representation of an Adler-32 checksum. Forcing a value of this type to whnf will cause it to be evaluated completely.
extractAdler32 :: Adler32 -> Word32 Source #
Extract the actual Adler-32 checksum from a Adler32
object.
makeAdler32 :: Integral a => Word32 -> a -> Adler32 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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 Source #
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.