public Hmac (ChecksumType digest_type, uint8[] key)

Creates a new Hmac, using the digest algorithm digest_type.

If the digest_type is not known, null is returned. A Hmac can be used to compute the HMAC of a key and an arbitrary binary blob, using different hashing algorithms.

A Hmac works by feeding a binary blob through update until the data is complete; the digest can then be extracted using get_string, which will return the checksum as a hexadecimal string; or get_digest, which will return a array of raw bytes. Once either get_string or get_digest have been called on a Hmac, the HMAC will be closed and it won't be possible to call update on it anymore.

Support for digests of type g_checksum_sha512 has been added in GLib 2.42. Support for g_checksum_sha384 was added in GLib 2.52.



the desired type of digest


the key for the HMAC


the length of the keys


the newly created Hmac, or null. Use g_hmac_unref to free the memory allocated by it.