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, use- GLib.Checksum.new(). To free a- GLib.Checksum, use- GLib.Checksum.free().- New in version 2.16. - 
classmethod new(checksum_type)[source]¶
- Parameters: - checksum_type ( - GLib.ChecksumType) – the desired type of checksum- Returns: - the newly created - GLib.Checksum, or- None. Use- GLib.Checksum.free() to free the memory allocated by it.- Return type: - GLib.Checksum- Creates a new - GLib.Checksum, using the checksum algorithm checksum_type. If the checksum_type is not known,- Noneis returned. A- GLib.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 through- GLib.Checksum.update() until there is data to be checked; the digest can then be extracted using- GLib.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 either- GLib.Checksum.get_string() or g_checksum_get_digest() have been called on a- GLib.Checksum, the checksum will be closed and it won’t be possible to call- GLib.Checksum.update() on it anymore.- New in version 2.16. 
 - 
classmethod type_get_length(checksum_type)[source]¶
- Parameters: - checksum_type ( - GLib.ChecksumType) – a- GLib.ChecksumType- Returns: - the checksum length, or -1 if checksum_type is not supported. - Return type: - int- Gets 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. Use- GLib.Checksum.free() when finished using it.- Return type: - GLib.Checksum- Copies a - GLib.Checksum. If self has been closed, by calling- GLib.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: - str- Gets the digest as a hexadecimal string. - Once this function has been called the - GLib.Checksumcan no longer be updated with- GLib.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 checksum- Feeds data into an existing - GLib.Checksum. The checksum must still be open, that is- GLib.Checksum.get_string() or g_checksum_get_digest() must not have been called on self.- New in version 2.16. 
 
- 
classmethod