| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.GLib.Structs.Checksum
Description
GLib provides a generic API for computing checksums (or ‘digests’) for a sequence of arbitrary bytes, using various hashing algorithms like MD5, SHA-1 and SHA-256. Checksums are commonly used in various environments and specifications.
To create a new GChecksum, use checksumNew. To free
a GChecksum, use checksumFree.
GLib supports incremental checksums using the GChecksum data
structure, by calling checksumUpdate as long as there’s data
available and then using checksumGetString or
Checksum.get_digest() to compute the checksum and return it
either as a string in hexadecimal form, or as a raw sequence of bytes. To
compute the checksum for binary blobs and nul-terminated strings in
one go, use the convenience functions computeChecksumForData
and computeChecksumForString, respectively.
Since: 2.16
Synopsis
- newtype Checksum = Checksum (ManagedPtr Checksum)
- type family ResolveChecksumMethod (t :: Symbol) o where ...
- data ChecksumCopyMethodInfo
- checksumCopy :: (HasCallStack, MonadIO m) => Checksum -> m Checksum
- data ChecksumFreeMethodInfo
- checksumFree :: (HasCallStack, MonadIO m) => Checksum -> m ()
- data ChecksumGetStringMethodInfo
- checksumGetString :: (HasCallStack, MonadIO m) => Checksum -> m Text
- checksumNew :: (HasCallStack, MonadIO m) => ChecksumType -> m (Maybe Checksum)
- data ChecksumResetMethodInfo
- checksumReset :: (HasCallStack, MonadIO m) => Checksum -> m ()
- checksumTypeGetLength :: (HasCallStack, MonadIO m) => ChecksumType -> m Int64
- data ChecksumUpdateMethodInfo
- checksumUpdate :: (HasCallStack, MonadIO m) => Checksum -> ByteString -> m ()
Exported types
Memory-managed wrapper type.
Constructors
| Checksum (ManagedPtr Checksum) |
Instances
Methods
Click to display all available methods, including inherited ones
type family ResolveChecksumMethod (t :: Symbol) o where ... Source #
Equations
| ResolveChecksumMethod "copy" o = ChecksumCopyMethodInfo | |
| ResolveChecksumMethod "free" o = ChecksumFreeMethodInfo | |
| ResolveChecksumMethod "reset" o = ChecksumResetMethodInfo | |
| ResolveChecksumMethod "update" o = ChecksumUpdateMethodInfo | |
| ResolveChecksumMethod "getString" o = ChecksumGetStringMethodInfo | |
| ResolveChecksumMethod l o = MethodResolutionFailed l o :: Type |
copy
data ChecksumCopyMethodInfo Source #
Instances
| (signature ~ m Checksum, MonadIO m) => OverloadedMethod ChecksumCopyMethodInfo Checksum signature Source # | |
Defined in GI.GLib.Structs.Checksum Methods overloadedMethod :: Checksum -> signature # | |
| OverloadedMethodInfo ChecksumCopyMethodInfo Checksum Source # | |
Defined in GI.GLib.Structs.Checksum Methods | |
Arguments
| :: (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
data ChecksumFreeMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod ChecksumFreeMethodInfo Checksum signature Source # | |
Defined in GI.GLib.Structs.Checksum Methods overloadedMethod :: Checksum -> signature # | |
| OverloadedMethodInfo ChecksumFreeMethodInfo Checksum Source # | |
Defined in GI.GLib.Structs.Checksum Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Checksum |
|
| -> m () |
Frees the memory allocated for checksum.
Since: 2.16
getString
data ChecksumGetStringMethodInfo Source #
Instances
| (signature ~ m Text, MonadIO m) => OverloadedMethod ChecksumGetStringMethodInfo Checksum signature Source # | |
Defined in GI.GLib.Structs.Checksum Methods overloadedMethod :: Checksum -> signature # | |
| OverloadedMethodInfo ChecksumGetStringMethodInfo Checksum Source # | |
Defined in GI.GLib.Structs.Checksum Methods | |
Arguments
| :: (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 a 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
Arguments
| :: (HasCallStack, MonadIO m) | |
| => ChecksumType |
|
| -> m (Maybe 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
data ChecksumResetMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod ChecksumResetMethodInfo Checksum signature Source # | |
Defined in GI.GLib.Structs.Checksum Methods overloadedMethod :: Checksum -> signature # | |
| OverloadedMethodInfo ChecksumResetMethodInfo Checksum Source # | |
Defined in GI.GLib.Structs.Checksum Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Checksum |
|
| -> m () |
Resets the state of the checksum back to its initial state.
Since: 2.18
typeGetLength
checksumTypeGetLength Source #
Arguments
| :: (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
data ChecksumUpdateMethodInfo Source #
Instances
| (signature ~ (ByteString -> m ()), MonadIO m) => OverloadedMethod ChecksumUpdateMethodInfo Checksum signature Source # | |
Defined in GI.GLib.Structs.Checksum Methods overloadedMethod :: Checksum -> signature # | |
| OverloadedMethodInfo ChecksumUpdateMethodInfo Checksum Source # | |
Defined in GI.GLib.Structs.Checksum Methods | |
Arguments
| :: (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