1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Data Checksums</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-utilities.html" title="GLib Utilities">
9 <link rel="prev" href="glib-Base64-Encoding.html" title="Base64 Encoding">
10 <link rel="next" href="glib-I18N.html" title="Internationalization">
11 <meta name="generator" content="GTK-Doc V1.13 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="chapter" href="glib.html" title="GLib Overview">
14 <link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
15 <link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
16 <link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
17 <link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
18 <link rel="chapter" href="tools.html" title="GLib Tools">
19 <link rel="index" href="api-index-full.html" title="Index">
20 <link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
21 <link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
22 <link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
23 <link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
24 <link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
25 <link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
26 <link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
27 <link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
28 <link rel="index" href="api-index-2-16.html" title="Index of new symbols in 2.16">
29 <link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
30 <link rel="index" href="api-index-2-20.html" title="Index of new symbols in 2.20">
31 <link rel="index" href="api-index-2-22.html" title="Index of new symbols in 2.22">
32 <link rel="index" href="api-index-2-24.html" title="Index of new symbols in 2.24">
34 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
35 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
37 <td><a accesskey="p" href="glib-Base64-Encoding.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
38 <td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
39 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
40 <th width="100%" align="center">GLib Reference Manual</th>
41 <td><a accesskey="n" href="glib-I18N.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
43 <tr><td colspan="5" class="shortcuts">
44 <a href="#glib-Data-Checksums.synopsis" class="shortcut">Top</a>
46 <a href="#glib-Data-Checksums.description" class="shortcut">Description</a>
49 <div class="refentry" title="Data Checksums">
50 <a name="glib-Data-Checksums"></a><div class="titlepage"></div>
51 <div class="refnamediv"><table width="100%"><tr>
53 <h2><span class="refentrytitle"><a name="glib-Data-Checksums.top_of_page"></a>Data Checksums</span></h2>
54 <p>Data Checksums — Computes the checksum for data</p>
56 <td valign="top" align="right"></td>
58 <div class="refsynopsisdiv" title="Synopsis">
59 <a name="glib-Data-Checksums.synopsis"></a><h2>Synopsis</h2>
60 <pre class="synopsis">
61 #include <glib.h>
63 enum <a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType">GChecksumType</a>;
64 <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="glib-Data-Checksums.html#g-checksum-type-get-length" title="g_checksum_type_get_length ()">g_checksum_type_get_length</a> (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type);
65 <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum">GChecksum</a>;
66 <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> * <a class="link" href="glib-Data-Checksums.html#g-checksum-new" title="g_checksum_new ()">g_checksum_new</a> (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type);
67 <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> * <a class="link" href="glib-Data-Checksums.html#g-checksum-copy" title="g_checksum_copy ()">g_checksum_copy</a> (const <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);
68 <span class="returnvalue">void</span> <a class="link" href="glib-Data-Checksums.html#g-checksum-free" title="g_checksum_free ()">g_checksum_free</a> (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);
69 <span class="returnvalue">void</span> <a class="link" href="glib-Data-Checksums.html#g-checksum-reset" title="g_checksum_reset ()">g_checksum_reset</a> (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);
70 <span class="returnvalue">void</span> <a class="link" href="glib-Data-Checksums.html#g-checksum-update" title="g_checksum_update ()">g_checksum_update</a> (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum,
71 const <a class="link" href="glib-Basic-Types.html#guchar" title="guchar"><span class="returnvalue">guchar</span></a> *data,
72 <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> length);
73 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()">g_checksum_get_string</a> (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);
74 <span class="returnvalue">void</span> <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest" title="g_checksum_get_digest ()">g_checksum_get_digest</a> (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum,
75 <a class="link" href="glib-Basic-Types.html#guint8" title="guint8"><span class="returnvalue">guint8</span></a> *buffer,
76 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> *digest_len);
78 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-data" title="g_compute_checksum_for_data ()">g_compute_checksum_for_data</a> (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type,
79 const <a class="link" href="glib-Basic-Types.html#guchar" title="guchar"><span class="returnvalue">guchar</span></a> *data,
80 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> length);
81 <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-string" title="g_compute_checksum_for_string ()">g_compute_checksum_for_string</a> (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type,
82 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *str,
83 <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> length);
86 <div class="refsect1" title="Description">
87 <a name="glib-Data-Checksums.description"></a><h2>Description</h2>
89 GLib provides a generic API for computing checksums (or "digests")
90 for a sequence of arbitrary bytes, using various hashing algorithms
91 like MD5, SHA-1 and SHA-256. Checksums are commonly used in various
92 environments and specifications.
95 GLib supports incremental checksums using the GChecksum data
96 structure, by calling <a class="link" href="glib-Data-Checksums.html#g-checksum-update" title="g_checksum_update ()"><code class="function">g_checksum_update()</code></a> as long as there's data
97 available and then using <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()"><code class="function">g_checksum_get_string()</code></a> or
98 <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest" title="g_checksum_get_digest ()"><code class="function">g_checksum_get_digest()</code></a> to compute the checksum and return it either
99 as a string in hexadecimal form, or as a raw sequence of bytes. To
100 compute the checksum for binary blobs and NUL-terminated strings in
101 one go, use the convenience functions <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-data" title="g_compute_checksum_for_data ()"><code class="function">g_compute_checksum_for_data()</code></a>
102 and <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-string" title="g_compute_checksum_for_string ()"><code class="function">g_compute_checksum_for_string()</code></a>, respectively.
105 Support for checksums has been added in GLib 2.16</p>
107 <div class="refsect1" title="Details">
108 <a name="glib-Data-Checksums.details"></a><h2>Details</h2>
109 <div class="refsect2" title="enum GChecksumType">
110 <a name="GChecksumType"></a><h3>enum GChecksumType</h3>
111 <pre class="programlisting">typedef enum {
118 The hashing algorithm to be used by <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> when performing the
122 Note that the <a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="type">GChecksumType</span></a> enumeration may be extended at a later
123 date to include new hashing algorithm types.</p>
124 <div class="variablelist"><table border="0">
125 <col align="left" valign="top">
128 <td><p><a name="G-CHECKSUM-MD5:CAPS"></a><span class="term"><code class="literal">G_CHECKSUM_MD5</code></span></p></td>
129 <td> Use the MD5 hashing algorithm
133 <td><p><a name="G-CHECKSUM-SHA1:CAPS"></a><span class="term"><code class="literal">G_CHECKSUM_SHA1</code></span></p></td>
134 <td> Use the SHA-1 hashing algorithm
138 <td><p><a name="G-CHECKSUM-SHA256:CAPS"></a><span class="term"><code class="literal">G_CHECKSUM_SHA256</code></span></p></td>
139 <td> Use the SHA-256 hashing algorithm
144 <p class="since">Since 2.16</p>
147 <div class="refsect2" title="g_checksum_type_get_length ()">
148 <a name="g-checksum-type-get-length"></a><h3>g_checksum_type_get_length ()</h3>
149 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> g_checksum_type_get_length (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type);</pre>
151 Gets the length in bytes of digests of type <em class="parameter"><code>checksum_type</code></em></p>
152 <div class="variablelist"><table border="0">
153 <col align="left" valign="top">
156 <td><p><span class="term"><em class="parameter"><code>checksum_type</code></em> :</span></p></td>
157 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="type">GChecksumType</span></a>
161 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
162 <td> the checksum length, or -1 if <em class="parameter"><code>checksum_type</code></em> is
169 <p class="since">Since 2.16</p>
172 <div class="refsect2" title="GChecksum">
173 <a name="GChecksum"></a><h3>GChecksum</h3>
174 <pre class="programlisting">typedef struct _GChecksum GChecksum;</pre>
176 An opaque structure representing a checksumming operation.
177 To create a new GChecksum, use <a class="link" href="glib-Data-Checksums.html#g-checksum-new" title="g_checksum_new ()"><code class="function">g_checksum_new()</code></a>. To free
178 a GChecksum, use <a class="link" href="glib-Data-Checksums.html#g-checksum-free" title="g_checksum_free ()"><code class="function">g_checksum_free()</code></a>.</p>
179 <p class="since">Since 2.16</p>
182 <div class="refsect2" title="g_checksum_new ()">
183 <a name="g-checksum-new"></a><h3>g_checksum_new ()</h3>
184 <pre class="programlisting"><a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> * g_checksum_new (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type);</pre>
186 Creates a new <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>, using the checksum algorithm <em class="parameter"><code>checksum_type</code></em>.
187 If the <em class="parameter"><code>checksum_type</code></em> is not known, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.
188 A <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> can be used to compute the checksum, or digest, of an
189 arbitrary binary blob, using different hashing algorithms.
192 A <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> works by feeding a binary blob through <a class="link" href="glib-Data-Checksums.html#g-checksum-update" title="g_checksum_update ()"><code class="function">g_checksum_update()</code></a>
193 until there is data to be checked; the digest can then be extracted
194 using <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()"><code class="function">g_checksum_get_string()</code></a>, which will return the checksum as a
195 hexadecimal string; or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest" title="g_checksum_get_digest ()"><code class="function">g_checksum_get_digest()</code></a>, which will return a
196 vector of raw bytes. Once either <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()"><code class="function">g_checksum_get_string()</code></a> or
197 <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest" title="g_checksum_get_digest ()"><code class="function">g_checksum_get_digest()</code></a> have been called on a <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>, the checksum
198 will be closed and it won't be possible to call <a class="link" href="glib-Data-Checksums.html#g-checksum-update" title="g_checksum_update ()"><code class="function">g_checksum_update()</code></a>
200 <div class="variablelist"><table border="0">
201 <col align="left" valign="top">
204 <td><p><span class="term"><em class="parameter"><code>checksum_type</code></em> :</span></p></td>
205 <td> the desired type of checksum
209 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
210 <td> the newly created <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
211 Use <a class="link" href="glib-Data-Checksums.html#g-checksum-free" title="g_checksum_free ()"><code class="function">g_checksum_free()</code></a> to free the memory allocated by it.
217 <p class="since">Since 2.16</p>
220 <div class="refsect2" title="g_checksum_copy ()">
221 <a name="g-checksum-copy"></a><h3>g_checksum_copy ()</h3>
222 <pre class="programlisting"><a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> * g_checksum_copy (const <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);</pre>
224 Copies a <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>. If <em class="parameter"><code>checksum</code></em> has been closed, by calling
225 <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()"><code class="function">g_checksum_get_string()</code></a> or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest" title="g_checksum_get_digest ()"><code class="function">g_checksum_get_digest()</code></a>, the copied
226 checksum will be closed as well.</p>
227 <div class="variablelist"><table border="0">
228 <col align="left" valign="top">
231 <td><p><span class="term"><em class="parameter"><code>checksum</code></em> :</span></p></td>
232 <td> the <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> to copy
236 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
237 <td> the copy of the passed <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>. Use <a class="link" href="glib-Data-Checksums.html#g-checksum-free" title="g_checksum_free ()"><code class="function">g_checksum_free()</code></a>
238 when finished using it.
244 <p class="since">Since 2.16</p>
247 <div class="refsect2" title="g_checksum_free ()">
248 <a name="g-checksum-free"></a><h3>g_checksum_free ()</h3>
249 <pre class="programlisting"><span class="returnvalue">void</span> g_checksum_free (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);</pre>
251 Frees the memory allocated for <em class="parameter"><code>checksum</code></em>.</p>
252 <div class="variablelist"><table border="0">
253 <col align="left" valign="top">
255 <td><p><span class="term"><em class="parameter"><code>checksum</code></em> :</span></p></td>
256 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>
260 <p class="since">Since 2.16</p>
263 <div class="refsect2" title="g_checksum_reset ()">
264 <a name="g-checksum-reset"></a><h3>g_checksum_reset ()</h3>
265 <pre class="programlisting"><span class="returnvalue">void</span> g_checksum_reset (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);</pre>
267 Resets the state of the <em class="parameter"><code>checksum</code></em> back to its initial state.</p>
268 <div class="variablelist"><table border="0">
269 <col align="left" valign="top">
271 <td><p><span class="term"><em class="parameter"><code>checksum</code></em> :</span></p></td>
272 <td> the <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> to reset
276 <p class="since">Since 2.18</p>
279 <div class="refsect2" title="g_checksum_update ()">
280 <a name="g-checksum-update"></a><h3>g_checksum_update ()</h3>
281 <pre class="programlisting"><span class="returnvalue">void</span> g_checksum_update (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum,
282 const <a class="link" href="glib-Basic-Types.html#guchar" title="guchar"><span class="returnvalue">guchar</span></a> *data,
283 <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> length);</pre>
285 Feeds <em class="parameter"><code>data</code></em> into an existing <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>. The checksum must still be
286 open, that is <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()"><code class="function">g_checksum_get_string()</code></a> or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest" title="g_checksum_get_digest ()"><code class="function">g_checksum_get_digest()</code></a> must
287 not have been called on <em class="parameter"><code>checksum</code></em>.</p>
288 <div class="variablelist"><table border="0">
289 <col align="left" valign="top">
292 <td><p><span class="term"><em class="parameter"><code>checksum</code></em> :</span></p></td>
293 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>
297 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
298 <td> buffer used to compute the checksum
302 <td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
303 <td> size of the buffer, or -1 if it is a null-terminated string.
308 <p class="since">Since 2.16</p>
311 <div class="refsect2" title="g_checksum_get_string ()">
312 <a name="g-checksum-get-string"></a><h3>g_checksum_get_string ()</h3>
313 <pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * g_checksum_get_string (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum);</pre>
315 Gets the digest as an hexadecimal string.
318 Once this function has been called the <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> can no longer be
319 updated with <a class="link" href="glib-Data-Checksums.html#g-checksum-update" title="g_checksum_update ()"><code class="function">g_checksum_update()</code></a>.
322 The hexadecimal characters will be lower case.</p>
323 <div class="variablelist"><table border="0">
324 <col align="left" valign="top">
327 <td><p><span class="term"><em class="parameter"><code>checksum</code></em> :</span></p></td>
328 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>
332 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
333 <td> the hexadecimal representation of the checksum. The
334 returned string is owned by the checksum and should not be modified
341 <p class="since">Since 2.16</p>
344 <div class="refsect2" title="g_checksum_get_digest ()">
345 <a name="g-checksum-get-digest"></a><h3>g_checksum_get_digest ()</h3>
346 <pre class="programlisting"><span class="returnvalue">void</span> g_checksum_get_digest (<a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="returnvalue">GChecksum</span></a> *checksum,
347 <a class="link" href="glib-Basic-Types.html#guint8" title="guint8"><span class="returnvalue">guint8</span></a> *buffer,
348 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> *digest_len);</pre>
350 Gets the digest from <em class="parameter"><code>checksum</code></em> as a raw binary vector and places it
351 into <em class="parameter"><code>buffer</code></em>. The size of the digest depends on the type of checksum.
354 Once this function has been called, the <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a> is closed and can
355 no longer be updated with <a class="link" href="glib-Data-Checksums.html#g-checksum-update" title="g_checksum_update ()"><code class="function">g_checksum_update()</code></a>.</p>
356 <div class="variablelist"><table border="0">
357 <col align="left" valign="top">
360 <td><p><span class="term"><em class="parameter"><code>checksum</code></em> :</span></p></td>
361 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksum" title="GChecksum"><span class="type">GChecksum</span></a>
365 <td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td>
370 <td><p><span class="term"><em class="parameter"><code>digest_len</code></em> :</span></p></td>
371 <td> an inout parameter. The caller initializes it to the size of <em class="parameter"><code>buffer</code></em>.
372 After the call it contains the length of the digest.
377 <p class="since">Since 2.16</p>
380 <div class="refsect2" title="g_compute_checksum_for_data ()">
381 <a name="g-compute-checksum-for-data"></a><h3>g_compute_checksum_for_data ()</h3>
382 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * g_compute_checksum_for_data (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type,
383 const <a class="link" href="glib-Basic-Types.html#guchar" title="guchar"><span class="returnvalue">guchar</span></a> *data,
384 <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="returnvalue">gsize</span></a> length);</pre>
386 Computes the checksum for a binary <em class="parameter"><code>data</code></em> of <em class="parameter"><code>length</code></em>. This is a
387 convenience wrapper for <a class="link" href="glib-Data-Checksums.html#g-checksum-new" title="g_checksum_new ()"><code class="function">g_checksum_new()</code></a>, <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string" title="g_checksum_get_string ()"><code class="function">g_checksum_get_string()</code></a>
388 and <a class="link" href="glib-Data-Checksums.html#g-checksum-free" title="g_checksum_free ()"><code class="function">g_checksum_free()</code></a>.
391 The hexadecimal string returned will be in lower case.</p>
392 <div class="variablelist"><table border="0">
393 <col align="left" valign="top">
396 <td><p><span class="term"><em class="parameter"><code>checksum_type</code></em> :</span></p></td>
397 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="type">GChecksumType</span></a>
401 <td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
402 <td> binary blob to compute the digest of
406 <td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
407 <td> length of <em class="parameter"><code>data</code></em>
411 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
412 <td> the digest of the binary data as a string in hexadecimal.
413 The returned string should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when done using it.
419 <p class="since">Since 2.16</p>
422 <div class="refsect2" title="g_compute_checksum_for_string ()">
423 <a name="g-compute-checksum-for-string"></a><h3>g_compute_checksum_for_string ()</h3>
424 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> * g_compute_checksum_for_string (<a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="returnvalue">GChecksumType</span></a> checksum_type,
425 const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *str,
426 <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="returnvalue">gssize</span></a> length);</pre>
428 Computes the checksum of a string.
431 The hexadecimal string returned will be in lower case.</p>
432 <div class="variablelist"><table border="0">
433 <col align="left" valign="top">
436 <td><p><span class="term"><em class="parameter"><code>checksum_type</code></em> :</span></p></td>
437 <td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType" title="enum GChecksumType"><span class="type">GChecksumType</span></a>
441 <td><p><span class="term"><em class="parameter"><code>str</code></em> :</span></p></td>
442 <td> the string to compute the checksum of
446 <td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
447 <td> the length of the string, or -1 if the string is null-terminated.
451 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
452 <td> the checksum as a hexadecimal string. The returned string
453 should be freed with <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a> when done using it.
459 <p class="since">Since 2.16</p>
465 Generated by GTK-Doc V1.13</div>