Glib::Checksum Class Reference
Computes the checksum for data. More...
Public Types | |
| enum | ChecksumType { CHECKSUM_MD5, CHECKSUM_SHA1, CHECKSUM_SHA256 } |
Public Member Functions | |
| Checksum () | |
| Checksum (GChecksum* castitem, bool make_a_copy=false) | |
| Checksum (const Checksum& src) | |
| Checksum& | operator= (const Checksum& src) |
| ~Checksum () | |
| GChecksum* | gobj () |
| const GChecksum* | gobj () const |
| GChecksum* | gobj_copy () const |
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. | |
| Checksum (ChecksumType checksum_type) | |
| Creates a new Checksum, using the checksum algorithm checksum_type. | |
| operator bool () const | |
| Returns true if the Checksum object is valid. | |
| void | update (const guchar* data, gsize length) |
| void | update (const std::string& data) |
| Feeds data into an existing Checksum. | |
| void | get_digest (guint8* buffer, gsize* digest_len) const |
| std::string | get_string () const |
Static Public Member Functions | |
| static std::string | compute_checksum (ChecksumType type, const guchar* data, gsize length) |
| static std::string | compute_checksum (ChecksumType type, const std::string& str) |
| Computes the checksum of a string. | |
| static gssize | get_length (ChecksumType checksum_type) |
| Gets the length in bytes of digests of type checksum_type. | |
Protected Attributes | |
| GChecksum* | gobject_ |
Related Functions | |
| (Note that these are not member functions.) | |
| Glib::Checksum | wrap (GChecksum* object, bool take_copy=false) |
| A Glib::wrap() method for this object. | |
Detailed Description
Computes the checksum for data.This is 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.
glibmm supports incremental checksums by calling update() as long as there's data available and then using get_string() or 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 NULL-terminated strings in one go, use the static compute_checksum() convenience functions().
Constructor & Destructor Documentation
| Glib::Checksum::Checksum | ( | ) |
| Glib::Checksum::Checksum | ( | GChecksum* | castitem, | |
| bool | make_a_copy = false | |||
| ) | [explicit] |
| Glib::Checksum::Checksum | ( | const Checksum& | src | ) |
| Glib::Checksum::~Checksum | ( | ) |
| Glib::Checksum::Checksum | ( | ChecksumType | checksum_type | ) | [explicit] |
Creates a new Checksum, using the checksum algorithm checksum_type.
If the checksum_type is not known, then operator bool() will return false.
- Parameters:
-
type checksum type, one of defined above.
Member Function Documentation
| GChecksum* Glib::Checksum::gobj | ( | ) | [inline] |
| const GChecksum* Glib::Checksum::gobj | ( | ) | const [inline] |
| GChecksum* Glib::Checksum::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
| Glib::Checksum::operator bool | ( | ) | const |
Returns true if the Checksum object is valid.
This will return false, for instance, if an unsupported checksum type was provided to the constructor.
| void Glib::Checksum::update | ( | const guchar * | data, | |
| gsize | length | |||
| ) |
| void Glib::Checksum::update | ( | const std::string & | data | ) |
Feeds data into an existing Checksum.
The checksum must still be open, that is get_string() or get_digest() must not have been called on the checksum.
- Parameters:
-
data Buffer used to compute the checksum
| void Glib::Checksum::get_digest | ( | guint8 * | buffer, | |
| gsize * | digest_len | |||
| ) | const |
| std::string Glib::Checksum::get_string | ( | ) | const |
| static std::string Glib::Checksum::compute_checksum | ( | ChecksumType | type, | |
| const guchar * | data, | |||
| gsize | length | |||
| ) | [static] |
| static std::string Glib::Checksum::compute_checksum | ( | ChecksumType | type, | |
| const std::string & | str | |||
| ) | [static] |
Computes the checksum of a string.
- Parameters:
-
checksum_type A ChecksumType str The string to compute the checksum of.
- Returns:
- The checksum as a hexadecimal string.
| static gssize Glib::Checksum::get_length | ( | ChecksumType | checksum_type | ) | [static] |
Gets the length in bytes of digests of type checksum_type.
- Parameters:
-
checksum_type A ChecksumType.
- Returns:
- The checksum length, or -1 if checksum_type is not supported.
Friends And Related Function Documentation
| Glib::Checksum wrap | ( | GChecksum* | object, | |
| bool | take_copy = false | |||
| ) | [related] |
A Glib::wrap() method for this object.
- Parameters:
-
object The C instance. take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
- Returns:
- A C++ instance that wraps this C instance.
Member Data Documentation
GChecksum* Glib::Checksum::gobject_ [protected] |
The documentation for this class was generated from the following file:
