Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
An opaque structure representing a checksumming operation.
To create a new GChecksum, use checksumNew
. To free
a GChecksum, use checksumFree
.
Since: 2.16
Synopsis
- newtype Checksum = Checksum (ManagedPtr Checksum)
- noChecksum :: Maybe Checksum
- checksumCopy :: (HasCallStack, MonadIO m) => Checksum -> m Checksum
- checksumFree :: (HasCallStack, MonadIO m) => Checksum -> m ()
- checksumGetString :: (HasCallStack, MonadIO m) => Checksum -> m Text
- checksumNew :: (HasCallStack, MonadIO m) => ChecksumType -> m Checksum
- checksumReset :: (HasCallStack, MonadIO m) => Checksum -> m ()
- checksumTypeGetLength :: (HasCallStack, MonadIO m) => ChecksumType -> m Int64
- checksumUpdate :: (HasCallStack, MonadIO m) => Checksum -> ByteString -> m ()
Exported types
Memory-managed wrapper type.
Instances
BoxedObject Checksum Source # | |
Methods
copy
:: (HasCallStack, MonadIO m) | |
=> Checksum |
|
-> m Checksum | Returns: the copy of the passed |
Copies a Checksum
. If checksum
has been closed, by calling
checksumGetString
or g_checksum_get_digest()
, the copied
checksum will be closed as well.
Since: 2.16
free
:: (HasCallStack, MonadIO m) | |
=> Checksum |
|
-> m () |
Frees the memory allocated for checksum
.
Since: 2.16
getString
:: (HasCallStack, MonadIO m) | |
=> Checksum |
|
-> m Text | Returns: the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed. |
Gets the digest as an hexadecimal string.
Once this function has been called the Checksum
can no longer be
updated with checksumUpdate
.
The hexadecimal characters will be lower case.
Since: 2.16
new
:: (HasCallStack, MonadIO m) | |
=> ChecksumType |
|
-> m Checksum | Returns: the newly created |
Creates a new Checksum
, using the checksum algorithm checksumType
.
If the checksumType
is not known, Nothing
is returned.
A Checksum
can be used to compute the checksum, or digest, of an
arbitrary binary blob, using different hashing algorithms.
A Checksum
works by feeding a binary blob through checksumUpdate
until there is data to be checked; the digest can then be extracted
using checksumGetString
, which will return the checksum as a
hexadecimal string; or g_checksum_get_digest()
, which will return a
vector of raw bytes. Once either checksumGetString
or
g_checksum_get_digest()
have been called on a Checksum
, the checksum
will be closed and it won't be possible to call checksumUpdate
on it anymore.
Since: 2.16
reset
:: (HasCallStack, MonadIO m) | |
=> Checksum |
|
-> m () |
Resets the state of the checksum
back to its initial state.
Since: 2.18
typeGetLength
checksumTypeGetLength Source #
:: (HasCallStack, MonadIO m) | |
=> ChecksumType |
|
-> m Int64 | Returns: the checksum length, or -1 if |
Gets the length in bytes of digests of type checksumType
Since: 2.16
update
:: (HasCallStack, MonadIO m) | |
=> Checksum |
|
-> ByteString |
|
-> m () |
Feeds data
into an existing Checksum
. The checksum must still be
open, that is checksumGetString
or g_checksum_get_digest()
must
not have been called on checksum
.
Since: 2.16