:right-sidebar: True Checksum =================================================================== .. currentmodule:: gi.repository.GLib .. versionadded:: 2.16 .. class:: Checksum(**kwargs) :no-contents-entry: :Constructors: :: new(checksum_type:GLib.ChecksumType) -> GLib.Checksum or None Constructors ------------ .. rst-class:: interim-class .. class:: Checksum :no-index: .. classmethod:: new(checksum_type: ~gi.repository.GLib.ChecksumType) -> ~gi.repository.GLib.Checksum | None Creates a new :obj:`~gi.repository.GLib.Checksum`, using the checksum algorithm ``checksum_type``. If the ``checksum_type`` is not known, :const:`None` is returned. A :obj:`~gi.repository.GLib.Checksum` can be used to compute the checksum, or digest, of an arbitrary binary blob, using different hashing algorithms. A :obj:`~gi.repository.GLib.Checksum` works by feeding a binary blob through :func:`~gi.repository.GLib.Checksum.update` until there is data to be checked; the digest can then be extracted using :func:`~gi.repository.GLib.Checksum.get_string`, which will return the checksum as a hexadecimal string; or :func:`~gi.repository.GLib.Checksum.get_digest`, which will return a vector of raw bytes. Once either :func:`~gi.repository.GLib.Checksum.get_string` or :func:`~gi.repository.GLib.Checksum.get_digest` have been called on a :obj:`~gi.repository.GLib.Checksum`, the checksum will be closed and it won't be possible to call :func:`~gi.repository.GLib.Checksum.update` on it anymore. .. versionadded:: 2.16 :param checksum_type: the desired type of checksum Methods ------- .. rst-class:: interim-class .. class:: Checksum :no-index: .. method:: free() -> None Frees the memory allocated for ``checksum``. .. versionadded:: 2.16 .. method:: get_string() -> str Gets the digest as a hexadecimal string. Once this function has been called the :obj:`~gi.repository.GLib.Checksum` can no longer be updated with :func:`~gi.repository.GLib.Checksum.update`. The hexadecimal characters will be lower case. .. versionadded:: 2.16 .. method:: reset() -> None Resets the state of the ``checksum`` back to its initial state. .. versionadded:: 2.18 .. method:: type_get_length(checksum_type: ~gi.repository.GLib.ChecksumType) -> int Gets the length in bytes of digests of type ``checksum_type`` .. versionadded:: 2.16 :param checksum_type: a :obj:`~gi.repository.GLib.ChecksumType` .. method:: update(data: ~typing.Sequence[int]) -> None Feeds ``data`` into an existing :obj:`~gi.repository.GLib.Checksum`. The checksum must still be open, that is :func:`~gi.repository.GLib.Checksum.get_string` or :func:`~gi.repository.GLib.Checksum.get_digest` must not have been called on ``checksum``. .. versionadded:: 2.16 :param data: buffer used to compute the checksum