Checksum

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 glib.checksum.Checksum, use glib.checksum.Checksum.new_. To free a glib.checksum.Checksum, use glib.checksum.Checksum.free.

GLib supports incremental checksums using the glib.checksum.Checksum data structure, by calling glib.checksum.Checksum.update as long as there’s data available and then using glib.checksum.Checksum.getString or glib.checksum.Checksum.getDigest 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 func@GLib.compute_checksum_for_data and func@GLib.compute_checksum_for_string, respectively.

Constructors

this
this(glib.types.ChecksumType checksumType)

Creates a new #GChecksum, using the checksum algorithm checksum_type. If the checksum_type 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.

Members

Functions

copy
glib.checksum.Checksum copy()

Copies a #GChecksum. If checksum has been closed, by calling glib.checksum.Checksum.getString or glib.checksum.Checksum.getDigest, the copied checksum will be closed as well.

getString
string getString()

Gets the digest as a hexadecimal string.

reset
void reset()

Resets the state of the checksum back to its initial state.

update
void update(ubyte[] data)

Feeds data into an existing #GChecksum. The checksum must still be open, that is glib.checksum.Checksum.getString or glib.checksum.Checksum.getDigest must not have been called on checksum.

Static functions

typeGetLength
ptrdiff_t typeGetLength(glib.types.ChecksumType checksumType)

Gets the length in bytes of digests of type checksum_type

Inherited Members

From Boxed

cInstancePtr
void* cInstancePtr;

Pointer to the C boxed value

getType
GType getType()

Get the GType of this boxed type.

gType
GType gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

copy_
void* copy_()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.