<refentry id="exo-MD5-functions">
<refmeta>
<refentrytitle>MD5 Functions</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>EXO Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>MD5 Functions</refname><refpurpose>MD5 hash implementation</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>

<synopsis>

#include &lt;exo/exo.h&gt;


            <link linkend="ExoMd5Digest">ExoMd5Digest</link>;
<link linkend="ExoMd5Digest">ExoMd5Digest</link>* <link linkend="exo-str-get-md5-digest">exo_str_get_md5_digest</link>        (const <link linkend="gchar">gchar</link> *contents);
<link linkend="gchar">gchar</link>*      <link linkend="exo-str-get-md5-str">exo_str_get_md5_str</link>             (const <link linkend="gchar">gchar</link> *contents);
<link linkend="ExoMd5Digest">ExoMd5Digest</link>* <link linkend="exo-md5-str-to-digest">exo_md5_str_to_digest</link>         (const <link linkend="gchar">gchar</link> *str_digest);
<link linkend="gchar">gchar</link>*      <link linkend="exo-md5-digest-to-str">exo_md5_digest_to_str</link>           (const <link linkend="ExoMd5Digest">ExoMd5Digest</link> *digest);
<link linkend="ExoMd5Digest">ExoMd5Digest</link>* <link linkend="exo-md5-digest-dup">exo_md5_digest_dup</link>            (const <link linkend="ExoMd5Digest">ExoMd5Digest</link> *digest);
<link linkend="void">void</link>        <link linkend="exo-md5-digest-free">exo_md5_digest_free</link>             (<link linkend="ExoMd5Digest">ExoMd5Digest</link> *digest);
<link linkend="guint">guint</link>       <link linkend="exo-md5-digest-hash">exo_md5_digest_hash</link>             (<link linkend="gconstpointer">gconstpointer</link> digest);
<link linkend="gboolean">gboolean</link>    <link linkend="exo-md5-digest-equal">exo_md5_digest_equal</link>            (<link linkend="gconstpointer">gconstpointer</link> digest1,
                                             <link linkend="gconstpointer">gconstpointer</link> digest2);


</synopsis>
</refsynopsisdiv>









<refsect1>
<title>Description</title>
<para>
  This is an implementation 16-byte MD5 hash algorithm with some
  related utility functions.
</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="ExoMd5Digest"/>ExoMd5Digest</title>
<indexterm><primary>ExoMd5Digest</primary></indexterm><programlisting>typedef struct {
  guchar digest[16];
} ExoMd5Digest;
</programlisting>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="exo-str-get-md5-digest"/>exo_str_get_md5_digest ()</title>
<indexterm><primary>exo_str_get_md5_digest</primary></indexterm><programlisting><link linkend="ExoMd5Digest">ExoMd5Digest</link>* exo_str_get_md5_digest        (const <link linkend="gchar">gchar</link> *contents);</programlisting>
<para>
Creates a binary MD5 digest of the string <parameter>contents</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>contents</parameter>&nbsp;:</term>
<listitem><simpara> The string to create a digest of.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> A new binary MD5 digest. It should be freed
              with <link linkend="exo-md5-digest-free"><function>exo_md5_digest_free()</function></link> when no longer
              needed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-str-get-md5-str"/>exo_str_get_md5_str ()</title>
<indexterm><primary>exo_str_get_md5_str</primary></indexterm><programlisting><link linkend="gchar">gchar</link>*      exo_str_get_md5_str             (const <link linkend="gchar">gchar</link> *contents);</programlisting>
<para>
Creates a character array MD5 digestof the string
<parameter>contents</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>contents</parameter>&nbsp;:</term>
<listitem><simpara> The string to create a digest of.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> A newly-allocated character array which
              should be free with <link linkend="g-free"><function>g_free()</function></link> when no
              longer needed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-md5-str-to-digest"/>exo_md5_str_to_digest ()</title>
<indexterm><primary>exo_md5_str_to_digest</primary></indexterm><programlisting><link linkend="ExoMd5Digest">ExoMd5Digest</link>* exo_md5_str_to_digest         (const <link linkend="gchar">gchar</link> *str_digest);</programlisting>
<para>
Converts thq <parameter>str_digest</parameter> character array digest
into a binary digest.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>str_digest</parameter>&nbsp;:</term>
<listitem><simpara> The character array digest to convert.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> A newly allocated binary digest. It should
              be freed with <link linkend="exo-md5-digest-free"><function>exo_md5_digest_free()</function></link> when
              no longer needed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-md5-digest-to-str"/>exo_md5_digest_to_str ()</title>
<indexterm><primary>exo_md5_digest_to_str</primary></indexterm><programlisting><link linkend="gchar">gchar</link>*      exo_md5_digest_to_str           (const <link linkend="ExoMd5Digest">ExoMd5Digest</link> *digest);</programlisting>
<para>
Converts the binary <parameter>digest</parameter> to an ASCII character array
digest. The result can be used as an ordinary C string.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>digest</parameter>&nbsp;:</term>
<listitem><simpara> The binary MD5 digest to convert.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> A newly-allocated character array which
              should be freed with <link linkend="g-free"><function>g_free()</function></link> when no
              longer needed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-md5-digest-dup"/>exo_md5_digest_dup ()</title>
<indexterm><primary>exo_md5_digest_dup</primary></indexterm><programlisting><link linkend="ExoMd5Digest">ExoMd5Digest</link>* exo_md5_digest_dup            (const <link linkend="ExoMd5Digest">ExoMd5Digest</link> *digest);</programlisting>
<para>
Duplicates the contents of the <parameter>digest</parameter> binary
MD5 digest.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>digest</parameter>&nbsp;:</term>
<listitem><simpara> The MD5 digest to copy.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> A new binary MD5 digest. It should
              be freed with <link linkend="exo-md5-digest-free"><function>exo_md5_digest_free()</function></link>
              when no longer needed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-md5-digest-free"/>exo_md5_digest_free ()</title>
<indexterm><primary>exo_md5_digest_free</primary></indexterm><programlisting><link linkend="void">void</link>        exo_md5_digest_free             (<link linkend="ExoMd5Digest">ExoMd5Digest</link> *digest);</programlisting>
<para>
Frees the memory allocated for the MD5 binary
<parameter>digest</parameter>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>digest</parameter>&nbsp;:</term>
<listitem><simpara> The MD5 digest to free.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-md5-digest-hash"/>exo_md5_digest_hash ()</title>
<indexterm><primary>exo_md5_digest_hash</primary></indexterm><programlisting><link linkend="guint">guint</link>       exo_md5_digest_hash             (<link linkend="gconstpointer">gconstpointer</link> digest);</programlisting>
<para>
Gets the numeric hash of <parameter>digest</parameter>, for use
in <link linkend="GHashTable"><type>GHashTable</type></link> and <link linkend="GCache"><type>GCache</type></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>digest</parameter>&nbsp;:</term>
<listitem><simpara> The <link linkend="ExoMd5Digest"><type>ExoMd5Digest</type></link> to hash.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> An unsigned integer hash of
              the digest;
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="exo-md5-digest-equal"/>exo_md5_digest_equal ()</title>
<indexterm><primary>exo_md5_digest_equal</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>    exo_md5_digest_equal            (<link linkend="gconstpointer">gconstpointer</link> digest1,
                                             <link linkend="gconstpointer">gconstpointer</link> digest2);</programlisting>
<para>
Tests the equality of <parameter>digest1</parameter> and <parameter>digest2</parameter>, useful for <link linkend="GHashTable"><type>GHashTable</type></link> and
<link linkend="GCashe"><type>GCashe</type></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>digest1</parameter>&nbsp;:</term>
<listitem><simpara> the first <link linkend="ExoMd5Digest"><type>ExoMd5Digest</type></link> to compare.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>digest2</parameter>&nbsp;:</term>
<listitem><simpara> the second <link linkend="ExoMd5Digest"><type>ExoMd5Digest</type></link> to compare.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> <literal>TRUE</literal> if both digests are equal, <literal>FALSE</literal> otherwise.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
