Class (GI Struct)

GLib-2.0GLibChecksumSince 2.16

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, use GLib.Checksum.new. To free a GLib.Checksum, use GLib.Checksum.free.

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

2.16

Index
  • Gets the digest as a hexadecimal string.

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

    The hexadecimal characters will be lower case.

    Returns string

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

    2.16

  • Feeds data into an existing GLib.Checksum. The checksum must still be open, that is g_checksum_get_string() or g_checksum_get_digest() must not have been called on checksum.

    Parameters

    • data: string | Uint8Array<ArrayBufferLike>

      buffer used to compute the checksum

    Returns void

    2.16