GLib.Hmac

Fields

None

Methods

get_digest (buffer)

get_string ()

unref ()

update (data)

Details

class GLib.Hmac

An opaque structure representing a HMAC operation. To create a new GLib.Hmac, use g_hmac_new(). To free a GLib.Hmac, use GLib.Hmac.unref().

New in version 2.30.

get_digest(buffer)[source]
Parameters:

buffer (bytes) – output buffer

Gets the digest from checksum as a raw binary array and places it into buffer. The size of the digest depends on the type of checksum.

Once this function has been called, the GLib.Hmac is closed and can no longer be updated with GLib.Checksum.update().

New in version 2.30.

get_string()[source]
Returns:

the hexadecimal representation of the HMAC. The returned string is owned by the HMAC and should not be modified or freed.

Return type:

str

Gets the HMAC as a hexadecimal string.

Once this function has been called the GLib.Hmac can no longer be updated with GLib.Hmac.update().

The hexadecimal characters will be lower case.

New in version 2.30.

unref()[source]

Atomically decrements the reference count of self by one.

If the reference count drops to 0, all keys and values will be destroyed, and all memory allocated by the hash table is released. This function is MT-safe and may be called from any thread. Frees the memory allocated for self.

New in version 2.30.

update(data)[source]
Parameters:

data (bytes) – buffer used to compute the checksum

Feeds data into an existing GLib.Hmac.

The HMAC must still be open, that is GLib.Hmac.get_string() or GLib.Hmac.get_digest() must not have been called on self.

New in version 2.30.