![]() |
![]() |
![]() |
GSK Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
GskHash; GskHash * gsk_hash_new_md5 (void); GskHash * gsk_hash_new_sha1 (void); GskHash * gsk_hash_new_crc32 (gboolean big_endian); void gsk_hash_feed (GskHash *hash, gconstpointer data, guint length); void gsk_hash_feed_str (GskHash *hash, const char *str); void gsk_hash_done (GskHash *hash); guint gsk_hash_get_size (GskHash *hash); void gsk_hash_get (GskHash *hash, guint8 *data_out); void gsk_hash_get_hex (GskHash *hash, gchar *hex_out); void gsk_hash_destroy (GskHash *hash);
These small objects can compute a hash-function
of a stream of data incrementally.
Just pass pieces of data to gsk_hash_feed()
and it will keep track of the hash-objects state.
Call gsk_hash_done()
to finish the hash off,
then use gsk_hash_get()
or gsk_hash_get_hex()
to
get the value of the hash.
typedef struct { /* The size of the hash-key (in bytes) */ guint size; } GskHash;
An abstract hashing object.
guint |
number of bytes in the hash. |
GskHash * gsk_hash_new_md5 (void);
Create a new MD5 hasher.
Returns : |
the newly allocated hash object. |
GskHash * gsk_hash_new_sha1 (void);
Create a new SHA1 hasher.
Returns : |
the newly allocated hash object. |
GskHash * gsk_hash_new_crc32 (gboolean big_endian);
Typically called as gsk_hash_new_crc32(G_BYTE_ORDER == G_BIG_ENDIAN).
|
whether to compute a big-endian crc32 hash. (As opposed to a little endian hash). |
Returns : |
the newly allocated hash object. |
void gsk_hash_feed (GskHash *hash, gconstpointer data, guint length);
Affect the hash incrementally; hash the given binary data.
You may call this function on little bits of data and it must have exactly the same effect is if you called it once with a larger slab of data.
|
the hash to feed data. |
|
binary data to accumulate in the hash. |
|
length of the binary data. |
void gsk_hash_feed_str (GskHash *hash, const char *str);
Hash the given binary data (incrementally).
You may mix calls to gsk_hash_feed()
and gsk_hash_feed_str()
.
|
the hash to feed data. |
|
a NUL-terminated string to feed to the hash. |
void gsk_hash_done (GskHash *hash);
Finish processing loose data for the hash. This may only be called once in the lifetime of the hash.
|
the hash to finish. |
guint gsk_hash_get_size (GskHash *hash);
Get the number of binary bytes that this function maps to.
|
the hash to query. |
Returns : |
the number of bytes of binary data in this hash. |
void gsk_hash_get (GskHash *hash, guint8 *data_out);
Get a binary hash value. This should be of the
size returned by gsk_hash_get_size()
.
|
the hash to query. |
|
binary buffer to fill with the hash value. |
void gsk_hash_get_hex (GskHash *hash, gchar *hex_out);
Get a hex hash value. This should be of the
size returned by (gsk_hash_get_size()
* 2 + 1).
|
the hash to query. |
|
buffer to fill with a NUL-terminated hex hash value. |
void gsk_hash_destroy (GskHash *hash);
Free memory used by the hash object.
|
the hash function. |