MD5

Name

MD5 -- MD5 Hash

Synopsis



struct      GMD5;
#define     GNET_MD5_HASH_LENGTH
GMD5*       gnet_md5_new                    (const guchar *buffer,
                                             guint length);
GMD5*       gnet_md5_new_string             (const gchar *str);
GMD5*       gnet_md5_clone                  (const GMD5 *gmd5);
void        gnet_md5_delete                 (GMD5 *gmd5);
GMD5*       gnet_md5_new_incremental        (void);
void        gnet_md5_update                 (GMD5 *gmd5,
                                             const guchar *buffer,
                                             guint length);
void        gnet_md5_final                  (GMD5 *gmd5);
gint        gnet_md5_equal                  (gconstpointer p1,
                                             gconstpointer p2);
guint       gnet_md5_hash                   (gconstpointer p);
guint8*     gnet_md5_get_digest             (const GMD5 *gmd5);
gchar*      gnet_md5_get_string             (const GMD5 *gmd5);
void        gnet_md5_copy_string            (const GMD5 *gmd5,
                                             guchar *buffer);

Description

Details

struct GMD5

struct GMD5;


GNET_MD5_HASH_LENGTH

#define     GNET_MD5_HASH_LENGTH

Length of the MD5 hash in bytes.


gnet_md5_new ()

GMD5*       gnet_md5_new                    (const guchar *buffer,
                                             guint length);

Create an MD5 hash of the buffer.

buffer : Buffer to hash
length : Length of that buffer
Returns : a new GMD5.


gnet_md5_new_string ()

GMD5*       gnet_md5_new_string             (const gchar *str);

Create an MD5 hash from a hexidecimal string. The string must be of length greater than or equal to GNET_MD5_HASH_LENGTH * 2.

str : Hexidecimal string
Returns : a new GMD5.


gnet_md5_clone ()

GMD5*       gnet_md5_clone                  (const GMD5 *gmd5);

Create a MD5 from another one.

gmd5 : MD5 to clone.
Returns : a new GMD5.


gnet_md5_delete ()

void        gnet_md5_delete                 (GMD5 *gmd5);

Delete a GMD5.

gmd5 : GMD5 to delete


gnet_md5_new_incremental ()

GMD5*       gnet_md5_new_incremental        (void);

Create a MD5 hash in incremental mode. After creating the GMD5, call gnet_md5_update() and gnet_md5_final().

Returns : new GMD5


gnet_md5_update ()

void        gnet_md5_update                 (GMD5 *gmd5,
                                             const guchar *buffer,
                                             guint length);

Update the hash with buffer. This may be called several times on an incremental hash before being finalized.

gmd5 : GMD5 to update
buffer : Buffer to add
length : Length of that buffer


gnet_md5_final ()

void        gnet_md5_final                  (GMD5 *gmd5);

Calcuate the final hash value. This is called on a GMD5 created using gnet_md5_new_incremental() and updated using gnet_md5_update() possibly several times.

gmd5 : GMD5 to finalize


gnet_md5_equal ()

gint        gnet_md5_equal                  (gconstpointer p1,
                                             gconstpointer p2);

Compare two GMD5's.

p1 : Pointer to first GMD5.
p2 : Pointer to second GMD5.
Returns : 1 if they are the same; 0 otherwise.


gnet_md5_hash ()

guint       gnet_md5_hash                   (gconstpointer p);

Hash the GMD5 hash value. This is not the actual MD5 hash, but a hash of this hash.

p : GMD5 to get hash value of
Returns : hash value.


gnet_md5_get_digest ()

guint8*     gnet_md5_get_digest             (const GMD5 *gmd5);

Get the MD5 hash digest.

gmd5 : GMD5 to get hash digest from
Returns : buffer containing the MD5 hash digest. The buffer is GNET_MD5_HASH_LENGTH bytes long. The GMD5 owns the buffer - do not free it.


gnet_md5_get_string ()

gchar*      gnet_md5_get_string             (const GMD5 *gmd5);

Get a hash string.

gmd5 : GMD5 to get hash from
Returns : Hexadecimal string representing the hash. The string is of length 2 * GNET_MD5_HASH_LENGTH and null terminated. The caller must free the string.


gnet_md5_copy_string ()

void        gnet_md5_copy_string            (const GMD5 *gmd5,
                                             guchar *buffer);

Copy the hash string into the buffer.

gmd5 : GMD5 to get hash from
buffer : Buffer of length of at least 2 * GNET_MD5_HASH_LENGTH