GLib.Checksum¶
Fields¶
None
Methods¶
| class | new (checksum_type) |
| class | type_get_length (checksum_type) |
copy () |
|
free () |
|
get_string () |
|
reset () |
|
update (data) |
Details¶
-
class
GLib.Checksum¶ An opaque structure representing a checksumming operation. To create a new
GLib.Checksum, useGLib.Checksum.new(). To free aGLib.Checksum, useGLib.Checksum.free().New in version 2.16.
-
classmethod
new(checksum_type)[source]¶ Parameters: checksum_type ( GLib.ChecksumType) – the desired type of checksumReturns: the newly created GLib.Checksum, orNone. UseGLib.Checksum.free() to free the memory allocated by it.Return type: GLib.ChecksumCreates a new
GLib.Checksum, using the checksum algorithm checksum_type. If the checksum_type is not known,Noneis returned. AGLib.Checksumcan be used to compute the checksum, or digest, of an arbitrary binary blob, using different hashing algorithms.A
GLib.Checksumworks by feeding a binary blob throughGLib.Checksum.update() until there is data to be checked; the digest can then be extracted usingGLib.Checksum.get_string(), which will return the checksum as a hexadecimal string; or g_checksum_get_digest(), which will return a vector of raw bytes. Once eitherGLib.Checksum.get_string() or g_checksum_get_digest() have been called on aGLib.Checksum, the checksum will be closed and it won’t be possible to callGLib.Checksum.update() on it anymore.New in version 2.16.
-
classmethod
type_get_length(checksum_type)[source]¶ Parameters: checksum_type ( GLib.ChecksumType) – aGLib.ChecksumTypeReturns: the checksum length, or -1 if checksum_type is not supported. Return type: intGets the length in bytes of digests of type checksum_type
New in version 2.16.
-
copy()[source]¶ Returns: the copy of the passed GLib.Checksum. UseGLib.Checksum.free() when finished using it.Return type: GLib.ChecksumCopies a
GLib.Checksum. If self has been closed, by callingGLib.Checksum.get_string() or g_checksum_get_digest(), the copied checksum will be closed as well.New in version 2.16.
-
get_string()[source]¶ Returns: the hexadecimal representation of the checksum. The returned string is owned by the checksum and should not be modified or freed. Return type: strGets the digest as a hexadecimal string.
Once this function has been called the
GLib.Checksumcan no longer be updated withGLib.Checksum.update().The hexadecimal characters will be lower case.
New in version 2.16.
-
update(data)[source]¶ Parameters: data ( bytes) – buffer used to compute the checksumFeeds data into an existing
GLib.Checksum. The checksum must still be open, that isGLib.Checksum.get_string() or g_checksum_get_digest() must not have been called on self.New in version 2.16.
-
classmethod