Copyright | (c) 2017 Red Hat Inc. |
---|---|
License | LGPL |
Maintainer | https://github.com/weldr |
Stability | alpha |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Functions for working with digest algorithms as used by the content store
- data DigestAlgorithm
- getDigestAlgorithm :: Text -> Maybe DigestAlgorithm
- digestName :: DigestAlgorithm -> String
- digestSize :: DigestAlgorithm -> Int
- digestInit :: DigestAlgorithm -> DigestContext
- data DigestContext
- digestUpdate :: ByteArrayAccess ba => DigestContext -> ba -> DigestContext
- digestUpdates :: ByteArrayAccess ba => DigestContext -> [ba] -> DigestContext
- digestFinalize :: DigestContext -> ObjectDigest
- digestByteString :: DigestAlgorithm -> ByteString -> ObjectDigest
- digestLazyByteString :: DigestAlgorithm -> ByteString -> ObjectDigest
- data ObjectDigest
- toHex :: ObjectDigest -> String
- fromByteString :: ByteArrayAccess ba => DigestAlgorithm -> ba -> Maybe ObjectDigest
Documentation
data DigestAlgorithm Source #
A DigestAlgorithm represents one specific hash algorithm.
getDigestAlgorithm :: Text -> Maybe DigestAlgorithm Source #
Given the Text
name of a digest algorithm, return a DigestAlgorithm
(or Nothing if we don't recognize the DigestAlgorithm's name).
digestName :: DigestAlgorithm -> String Source #
Get the name of this DigestAlgorithm
.
digestSize :: DigestAlgorithm -> Int Source #
The size of the ObjectDigest
returned by this DigestAlgorithm
.
digestInit :: DigestAlgorithm -> DigestContext Source #
Initialize a new DigestContext
for this DigestAlgorithm
.
data DigestContext Source #
Holds the context for a given instance of a DigestAlgorithm
.
digestUpdate :: ByteArrayAccess ba => DigestContext -> ba -> DigestContext Source #
Update the DigestContext
with one 'ByteString'/'Bytes'/etc item.
digestUpdates :: ByteArrayAccess ba => DigestContext -> [ba] -> DigestContext Source #
Update the DigestContext
with many 'ByteString'/'Bytes'/etc. items.
digestFinalize :: DigestContext -> ObjectDigest Source #
Finish the digest, returning an ObjectDigest
.
digestByteString :: DigestAlgorithm -> ByteString -> ObjectDigest Source #
Hash a strict ByteString
into an ObjectDigest
.
digestLazyByteString :: DigestAlgorithm -> ByteString -> ObjectDigest Source #
Hash a lazy ByteString
into an ObjectDigest
.
data ObjectDigest Source #
ObjectDigest is the (binary) representation of a digest.
toHex :: ObjectDigest -> String Source #
Convert an ObjectDigest
to its hex representation.
TODO: probably more efficient if we can just coerce the converted Bytes..
fromByteString :: ByteArrayAccess ba => DigestAlgorithm -> ba -> Maybe ObjectDigest Source #
Check and convert a ByteString
into an ObjectDigest
.