2007-12-04 17:31:51 +01:00
|
|
|
/* gchecksum.h - data hashing functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Emmanuele Bassi <ebassi@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2017-01-05 12:47:07 +01:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2007-12-04 17:31:51 +01:00
|
|
|
* License as published by the Free Software Foundation; either
|
2017-01-05 12:47:07 +01:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2007-12-04 17:31:51 +01:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2017-01-05 12:47:07 +01:00
|
|
|
* Lesser General Public License for more details.
|
2007-12-04 17:31:51 +01:00
|
|
|
*
|
2017-01-05 12:47:07 +01:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2007-12-04 17:31:51 +01:00
|
|
|
*/
|
|
|
|
|
2012-12-28 05:43:14 +01:00
|
|
|
#ifndef __G_CHECKSUM_H__
|
|
|
|
#define __G_CHECKSUM_H__
|
|
|
|
|
2011-10-12 06:24:46 +02:00
|
|
|
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
|
2008-03-14 20:30:38 +01:00
|
|
|
#error "Only <glib.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2007-12-04 17:31:51 +01:00
|
|
|
#include <glib/gtypes.h>
|
2012-07-31 16:47:45 +02:00
|
|
|
#include <glib/gbytes.h>
|
2007-12-04 17:31:51 +01:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GChecksumType:
|
|
|
|
* @G_CHECKSUM_MD5: Use the MD5 hashing algorithm
|
|
|
|
* @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm
|
|
|
|
* @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm
|
2016-09-26 19:40:22 +02:00
|
|
|
* @G_CHECKSUM_SHA384: Use the SHA-384 hashing algorithm (Since: 2.51)
|
2016-07-21 11:21:52 +02:00
|
|
|
* @G_CHECKSUM_SHA512: Use the SHA-512 hashing algorithm (Since: 2.36)
|
2007-12-04 17:31:51 +01:00
|
|
|
*
|
|
|
|
* The hashing algorithm to be used by #GChecksum when performing the
|
|
|
|
* digest of some data.
|
|
|
|
*
|
2010-09-04 01:49:34 +02:00
|
|
|
* Note that the #GChecksumType enumeration may be extended at a later
|
|
|
|
* date to include new hashing algorithm types.
|
2007-12-04 17:31:51 +01:00
|
|
|
*
|
|
|
|
* Since: 2.16
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
G_CHECKSUM_MD5,
|
|
|
|
G_CHECKSUM_SHA1,
|
2012-11-16 18:20:09 +01:00
|
|
|
G_CHECKSUM_SHA256,
|
2017-02-26 11:52:17 +01:00
|
|
|
G_CHECKSUM_SHA512,
|
|
|
|
G_CHECKSUM_SHA384
|
2007-12-04 17:31:51 +01:00
|
|
|
} GChecksumType;
|
|
|
|
|
2008-06-15 02:03:54 +02:00
|
|
|
/**
|
|
|
|
* GChecksum:
|
|
|
|
*
|
|
|
|
* An opaque structure representing a checksumming operation.
|
|
|
|
* To create a new GChecksum, use g_checksum_new(). To free
|
|
|
|
* a GChecksum, use g_checksum_free().
|
|
|
|
*
|
|
|
|
* Since: 2.16
|
|
|
|
*/
|
2007-12-04 17:31:51 +01:00
|
|
|
typedef struct _GChecksum GChecksum;
|
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
gssize g_checksum_type_get_length (GChecksumType checksum_type);
|
2007-12-19 19:53:27 +01:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
GChecksum * g_checksum_new (GChecksumType checksum_type);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
void g_checksum_reset (GChecksum *checksum);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
GChecksum * g_checksum_copy (const GChecksum *checksum);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
void g_checksum_free (GChecksum *checksum);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
void g_checksum_update (GChecksum *checksum,
|
|
|
|
const guchar *data,
|
|
|
|
gssize length);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2011-03-13 03:50:45 +01:00
|
|
|
const gchar * g_checksum_get_string (GChecksum *checksum);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
void g_checksum_get_digest (GChecksum *checksum,
|
|
|
|
guint8 *buffer,
|
|
|
|
gsize *digest_len);
|
2007-12-04 17:31:51 +01:00
|
|
|
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
gchar *g_compute_checksum_for_data (GChecksumType checksum_type,
|
|
|
|
const guchar *data,
|
|
|
|
gsize length);
|
2012-12-06 20:04:59 +01:00
|
|
|
GLIB_AVAILABLE_IN_ALL
|
2010-09-04 01:49:34 +02:00
|
|
|
gchar *g_compute_checksum_for_string (GChecksumType checksum_type,
|
|
|
|
const gchar *str,
|
|
|
|
gssize length);
|
2007-12-04 17:31:51 +01:00
|
|
|
|
2012-07-31 16:47:45 +02:00
|
|
|
GLIB_AVAILABLE_IN_2_34
|
|
|
|
gchar *g_compute_checksum_for_bytes (GChecksumType checksum_type,
|
|
|
|
GBytes *data);
|
|
|
|
|
2007-12-04 17:31:51 +01:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __G_CHECKSUM_H__ */
|