GChecksumType: : Use the MD5 hashing algorithm : Use the SHA-1 hashing algorithm : Use the SHA-256 hashing algorithm
The hashing algorithm to be used by GChecksum when performing the digest of some data.
Note that the GChecksumType enumeration may be extended at a later date to include new hashing algorithm types.
Since: 2.16
Enumerator | Value | Description |
---|---|---|
G_CHECKSUM_MD5 | ||
G_CHECKSUM_SHA1 | ||
G_CHECKSUM_SHA256 |
typedef struct _GChecksum | GChecksum |
GChecksum:
An opaque structure representing a checksumming operation. To create a new GChecksum, use g_checksum_new(). To free a GChecksum, use g_checksum_free().
Since: 2.16
IMPORT_C gssize | g_checksum_type_get_length | ( | GChecksumType | checksum_type | ) |
g_checksum_type_get_length: : a GChecksumType
Gets the length in bytes of digests of type
Return value: the checksum length, or -1 if is not supported.
Since: 2.16
IMPORT_C GChecksum * | g_checksum_new | ( | GChecksumType | checksum_type | ) |
g_checksum_new: : the desired type of checksum
Creates a new GChecksum, using the checksum algorithm . If the is not known, NULL is returned. A GChecksum can be used to compute the checksum, or digest, of an arbitrary binary blob, using different hashing algorithms.
A GChecksum works by feeding a binary blob through g_checksum_update() until there is data to be checked; the digest can then be extracted using g_checksum_get_string(), which will return the checksum as a hexadecimal string; or g_checksum_get_digest(), which will return a vector of raw bytes. Once either g_checksum_get_string() or g_checksum_get_digest() have been called on a GChecksum, the checksum will be closed and it won't be possible to call g_checksum_update() on it anymore.
Return value: the newly created GChecksum, or NULL. Use g_checksum_free() to free the memory allocated by it.
Since: 2.16
IMPORT_C void | g_checksum_reset | ( | GChecksum * | checksum | ) |
g_checksum_reset: : the GChecksum to reset
Resets the state of the back to its initial state.
Since: 2.18
g_checksum_copy: : the GChecksum to copy
Copies a GChecksum. If has been closed, by calling g_checksum_get_string() or g_checksum_get_digest(), the copied checksum will be closed as well.
Return value: the copy of the passed GChecksum. Use g_checksum_free() when finished using it.
Since: 2.16
IMPORT_C void | g_checksum_free | ( | GChecksum * | checksum | ) |
g_checksum_update: : a GChecksum : buffer used to compute the checksum : size of the buffer, or -1 if it is a null-terminated string.
Feeds into an existing GChecksum. The checksum must still be open, that is g_checksum_get_string() or g_checksum_get_digest() must not have been called on .
Since: 2.16
g_checksum_get_string: : a GChecksum
Gets the digest as an hexadecimal string.
Once this function has been called the GChecksum can no longer be updated with g_checksum_update().
The hexadecimal characters will be lower case.
Return value: the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed.
Since: 2.16
g_checksum_get_digest: : a GChecksum : output buffer : an inout parameter. The caller initializes it to the size of . After the call it contains the length of the digest.
Gets the digest from as a raw binary vector and places it into . The size of the digest depends on the type of checksum.
Once this function has been called, the GChecksum is closed and can no longer be updated with g_checksum_update().
Since: 2.16
IMPORT_C gchar * | g_compute_checksum_for_data | ( | GChecksumType | checksum_type, |
const guchar * | data, | |||
gsize | length | |||
) |
g_compute_checksum_for_data: : a GChecksumType : binary blob to compute the digest of : length of
Computes the checksum for a binary of . This is a convenience wrapper for g_checksum_new(), g_checksum_get_string() and g_checksum_free().
The hexadecimal string returned will be in lower case.
Return value: the digest of the binary data as a string in hexadecimal. The returned string should be freed with g_free() when done using it.
Since: 2.16
IMPORT_C gchar * | g_compute_checksum_for_string | ( | GChecksumType | checksum_type, |
const gchar * | str, | |||
gssize | length | |||
) |
g_compute_checksum_for_string: : a GChecksumType : the string to compute the checksum of : the length of the string, or -1 if the string is null-terminated.
Computes the checksum of a string.
The hexadecimal string returned will be in lower case.
Return value: the checksum as a hexadecimal string. The returned string should be freed with g_free() when done using it.
Since: 2.16