⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-data-checksums.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Data Checksums</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-utilities.html" title="GLib Utilities"><link rel="prev" href="glib-Base64-Encoding.html" title="Base64 Encoding"><link rel="next" href="glib-I18N.html" title="Internationalization"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"><link rel="index" href="ix09.html" title="Index of new symbols in 2.14"><link rel="index" href="ix10.html" title="Index of new symbols in 2.16"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Base64-Encoding.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-I18N.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id3027238" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id3027541" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="glib-Data-Checksums"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3027238"></a><span class="refentrytitle">Data Checksums</span></h2><p>Data Checksums &#8212; Computes the checksum for data</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;glib.h&gt;enum                <a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a>;<a class="link" href="glib-Basic-Types.html#gssize">gssize</a>              <a class="link" href="glib-Data-Checksums.html#g-checksum-type-get-length">g_checksum_type_get_length</a>          (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);                    <a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>;<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          <a class="link" href="glib-Data-Checksums.html#g-checksum-new">g_checksum_new</a>                      (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          <a class="link" href="glib-Data-Checksums.html#g-checksum-copy">g_checksum_copy</a>                     (const <a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);void                <a class="link" href="glib-Data-Checksums.html#g-checksum-free">g_checksum_free</a>                     (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);void                <a class="link" href="glib-Data-Checksums.html#g-checksum-update">g_checksum_update</a>                   (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum,                                                         const <a class="link" href="glib-Basic-Types.html#guchar">guchar</a> *data,                                                         <a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length);const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*        <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string">g_checksum_get_string</a>               (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);void                <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest">g_checksum_get_digest</a>               (<a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum,                                                         <a class="link" href="glib-Basic-Types.html#guint8">guint8</a> *buffer,                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> *digest_len);<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-data">g_compute_checksum_for_data</a>         (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type,                                                         const <a class="link" href="glib-Basic-Types.html#guchar">guchar</a> *data,                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> length);<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-string">g_compute_checksum_for_string</a>       (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *str,                                                         <a class="link" href="glib-Basic-Types.html#gssize">gssize</a> length);</pre></div><div class="refsect1" lang="en"><a name="id3027541"></a><h2>Description</h2><p>GLib provides a generic API for computing checksums (or "digests") for asequence of arbitrary bytes, using various hashing algorithms like MD5,SHA-1 and SHA-256. Checksums are commonly used in various environments andspecifications.</p><p>GLib supports incremental checksums using the GChecksum data structure, bycalling <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a> as long as there's data available and then using<a class="link" href="glib-Data-Checksums.html#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"><code class="function">g_checksum_get_digest()</code></a> to compute the checksumand return it either as a string in hexadecimal form, or as a raw sequenceof bytes. To compute the checksum for binary blobs and NUL-terminated stringsin one go, use the convenience functions <a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-data"><code class="function">g_compute_checksum_for_data()</code></a> and<a class="link" href="glib-Data-Checksums.html#g-compute-checksum-for-string"><code class="function">g_compute_checksum_for_string()</code></a>, respectively.</p><p>Support for checksums has been added in GLib 2.16</p></div><div class="refsect1" lang="en"><a name="id3027628"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3027639"></a><h3><a name="GChecksumType"></a>enum GChecksumType</h3><a class="indexterm" name="id3027653"></a><pre class="programlisting">typedef enum {  G_CHECKSUM_MD5,  G_CHECKSUM_SHA1,  G_CHECKSUM_SHA256} GChecksumType;</pre><p>The hashing algorithm to be used by <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> when performing thedigest of some data.</p><p>Note that the <a class="link" href="glib-Data-Checksums.html#GChecksumType"><span class="type">GChecksumType</span></a> enumeration may be extended at a later date to include new hashing algorithm types.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="G-CHECKSUM-MD5:CAPS"></a><code class="literal">G_CHECKSUM_MD5</code></span></p></td><td> Use the MD5 hashing algorithm</td></tr><tr><td><p><span class="term"><a name="G-CHECKSUM-SHA1:CAPS"></a><code class="literal">G_CHECKSUM_SHA1</code></span></p></td><td> Use the SHA-1 hashing algorithm</td></tr><tr><td><p><span class="term"><a name="G-CHECKSUM-SHA256:CAPS"></a><code class="literal">G_CHECKSUM_SHA256</code></span></p></td><td> Use the SHA-256 hashing algorithm</td></tr></tbody></table></div><p class="since">Since  2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3027775"></a><h3><a name="g-checksum-type-get-length"></a>g_checksum_type_get_length ()</h3><a class="indexterm" name="id3027790"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gssize">gssize</a>              g_checksum_type_get_length          (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);</pre><p>Gets the length in bytes of digests of type <em class="parameter"><code>checksum_type</code></em></p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>checksum_type</code></em>&#160;:</span></p></td><td> a <a class="link" href="glib-Data-Checksums.html#GChecksumType"><span class="type">GChecksumType</span></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the checksum length, or -1 if <em class="parameter"><code>checksum_type</code></em> isnot supported.</td></tr></tbody></table></div><p class="since">Since  2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3027878"></a><h3><a name="GChecksum"></a>GChecksum</h3><a class="indexterm" name="id3027890"></a><pre class="programlisting">typedef struct _GChecksum GChecksum;</pre><p></p></div><hr><div class="refsect2" lang="en"><a name="id3027905"></a><h3><a name="g-checksum-new"></a>g_checksum_new ()</h3><a class="indexterm" name="id3027920"></a><pre class="programlisting"><a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          g_checksum_new                      (<a class="link" href="glib-Data-Checksums.html#GChecksumType">GChecksumType</a> checksum_type);</pre><p>Creates a new <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>, using the checksum algorithm <em class="parameter"><code>checksum_type</code></em>. If the <em class="parameter"><code>checksum_type</code></em> is not known, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.A <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a> can be used to compute the checksum, or digest, of anarbitrary binary blob, using different hashing algorithms.</p><p>A <a class="link" href="glib-Data-Checksums.html#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"><code class="function">g_checksum_update()</code></a>until there is data to be checked; the digest can then be extractedusing <a class="link" href="glib-Data-Checksums.html#g-checksum-get-string"><code class="function">g_checksum_get_string()</code></a>, which will return the checksum as ahexadecimal string; or <a class="link" href="glib-Data-Checksums.html#g-checksum-get-digest"><code class="function">g_checksum_get_digest()</code></a>, which will return avector of raw bytes. Once either <a class="link" href="glib-Data-Checksums.html#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"><code class="function">g_checksum_get_digest()</code></a> have been called on a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>, the checksumwill be closed and it won't be possible to call <a class="link" href="glib-Data-Checksums.html#g-checksum-update"><code class="function">g_checksum_update()</code></a>on it anymore.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>checksum_type</code></em>&#160;:</span></p></td><td> the desired type of checksum</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the newly created <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.   Use <a class="link" href="glib-Data-Checksums.html#g-checksum-free"><code class="function">g_checksum_free()</code></a> to free the memory allocated by it.</td></tr></tbody></table></div><p class="since">Since  2.16</p></div><hr><div class="refsect2" lang="en"><a name="id3028148"></a><h3><a name="g-checksum-copy"></a>g_checksum_copy ()</h3><a class="indexterm" name="id3028163"></a><pre class="programlisting"><a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a>*          g_checksum_copy                     (const <a class="link" href="glib-Data-Checksums.html#GChecksum">GChecksum</a> *checksum);</pre><p>Copies a <a class="link" href="glib-Data-Checksums.html#GChecksum"><span class="type">GChecksum</span></a>. If <em class="parameter"><code>checksum</code></em> has been closed, by calling<a class="link" href="glib-Data-Checksums.html#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"><code class="function">g_checksum_get_digest()</code></a>, the copiedchecksum will be closed as well.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>checksum</code></em>&#160;:</span></p></td>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -