## MD5 Functions MD5 Functions — MD5 hash implementation |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <exo/exo.h>

                        ExoMd5Digest;
    ExoMd5Digest *      exo_str_get_md5_digest              (const gchar *contents);
    gchar *             exo_str_get_md5_str                 (const gchar *contents);
    ExoMd5Digest *      exo_md5_str_to_digest               (const gchar *str_digest);
    gchar *             exo_md5_digest_to_str               (const ExoMd5Digest *digest);
    ExoMd5Digest *      exo_md5_digest_dup                  (const ExoMd5Digest *digest);
    void                exo_md5_digest_free                 (ExoMd5Digest *digest);
    guint               exo_md5_digest_hash                 (gconstpointer digest);
    gboolean            exo_md5_digest_equal                (gconstpointer digest1,
                                                             gconstpointer digest2);

## Description

This is an implementation 16-byte MD5 hash algorithm with some related utility functions.

## Details

### ExoMd5Digest

    typedef struct {
      guchar digest[16];
    } ExoMd5Digest;

Structure to represent a MD5 digest.

guchar `digest`[16]; | the MD5 digest.

### exo_str_get_md5_digest ()

    ExoMd5Digest *      exo_str_get_md5_digest              (const gchar *contents);

Creates a binary MD5 digest of the string `contents`.

`contents` : | The string to create a digest of.
Returns : | A new binary MD5 digest. It should be freed with `exo_md5_digest_free()` when no longer needed.

### exo_str_get_md5_str ()

    gchar *             exo_str_get_md5_str                 (const gchar *contents);

Creates a character array MD5 digestof the string `contents`.

`contents` : | The string to create a digest of.
Returns : | A newly-allocated character array which should be free with `g_free()` when no longer needed.

### exo_md5_str_to_digest ()

    ExoMd5Digest *      exo_md5_str_to_digest               (const gchar *str_digest);

Converts thq `str_digest` character array digest into a binary digest.

`str_digest` : | The character array digest to convert.
Returns : | A newly allocated binary digest. It should be freed with `exo_md5_digest_free()` when no longer needed.

### exo_md5_digest_to_str ()

    gchar *             exo_md5_digest_to_str               (const ExoMd5Digest *digest);

Converts the binary `digest` to an ASCII character array digest. The result can be used as an ordinary C string.

`digest` : | The binary MD5 digest to convert.
Returns : | A newly-allocated character array which should be freed with `g_free()` when no longer needed.

### exo_md5_digest_dup ()

    ExoMd5Digest *      exo_md5_digest_dup                  (const ExoMd5Digest *digest);

Duplicates the contents of the `digest` binary MD5 digest.

`digest` : | The MD5 digest to copy.
Returns : | A new binary MD5 digest. It should be freed with `exo_md5_digest_free()` when no longer needed.

### exo_md5_digest_free ()

    void                exo_md5_digest_free                 (ExoMd5Digest *digest);

Frees the memory allocated for the MD5 binary `digest`.

`digest` : | The MD5 digest to free.

### exo_md5_digest_hash ()

    guint               exo_md5_digest_hash                 (gconstpointer digest);

Gets the numeric hash of `digest`, for use in GHashTable and GCache.

`digest` : | The ExoMd5Digest to hash.
Returns : | An unsigned integer hash of the digest;

### exo_md5_digest_equal ()

    gboolean            exo_md5_digest_equal                (gconstpointer digest1,
                                                             gconstpointer digest2);

Tests the equality of `digest1` and `digest2`, useful for GHashTable and GCashe.

`digest1` : | the first ExoMd5Digest to compare.
`digest2` : | the second ExoMd5Digest to compare.
Returns : | `TRUE` if both digests are equal, `FALSE` otherwise.