Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-06 08:41:16

0001 /* gchecksum.h - data hashing functions
0002  *
0003  * Copyright (C) 2007  Emmanuele Bassi  <ebassi@gnome.org>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-or-later
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Lesser General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2.1 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public License
0018  * along with this library; if not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #ifndef __G_CHECKSUM_H__
0022 #define __G_CHECKSUM_H__
0023 
0024 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
0025 #error "Only <glib.h> can be included directly."
0026 #endif
0027 
0028 #include <glib/gtypes.h>
0029 #include <glib/gbytes.h>
0030 
0031 G_BEGIN_DECLS
0032 
0033 /**
0034  * GChecksumType:
0035  * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm
0036  * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm
0037  * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm
0038  * @G_CHECKSUM_SHA384: Use the SHA-384 hashing algorithm (Since: 2.51)
0039  * @G_CHECKSUM_SHA512: Use the SHA-512 hashing algorithm (Since: 2.36)
0040  *
0041  * The hashing algorithm to be used by #GChecksum when performing the
0042  * digest of some data.
0043  *
0044  * Note that the #GChecksumType enumeration may be extended at a later
0045  * date to include new hashing algorithm types.
0046  *
0047  * Since: 2.16
0048  */
0049 typedef enum {
0050   G_CHECKSUM_MD5,
0051   G_CHECKSUM_SHA1,
0052   G_CHECKSUM_SHA256,
0053   G_CHECKSUM_SHA512,
0054   G_CHECKSUM_SHA384
0055 } GChecksumType;
0056 
0057 typedef struct _GChecksum       GChecksum;
0058 
0059 GLIB_AVAILABLE_IN_ALL
0060 gssize                g_checksum_type_get_length    (GChecksumType    checksum_type);
0061 
0062 GLIB_AVAILABLE_IN_ALL
0063 GChecksum *           g_checksum_new                (GChecksumType    checksum_type);
0064 GLIB_AVAILABLE_IN_ALL
0065 void                  g_checksum_reset              (GChecksum       *checksum);
0066 GLIB_AVAILABLE_IN_ALL
0067 GChecksum *           g_checksum_copy               (const GChecksum *checksum);
0068 GLIB_AVAILABLE_IN_ALL
0069 void                  g_checksum_free               (GChecksum       *checksum);
0070 GLIB_AVAILABLE_IN_ALL
0071 void                  g_checksum_update             (GChecksum       *checksum,
0072                                                      const guchar    *data,
0073                                                      gssize           length);
0074 GLIB_AVAILABLE_IN_ALL
0075 const gchar *         g_checksum_get_string         (GChecksum       *checksum);
0076 GLIB_AVAILABLE_IN_ALL
0077 void                  g_checksum_get_digest         (GChecksum       *checksum,
0078                                                      guint8          *buffer,
0079                                                      gsize           *digest_len);
0080 
0081 GLIB_AVAILABLE_IN_ALL
0082 gchar                *g_compute_checksum_for_data   (GChecksumType    checksum_type,
0083                                                      const guchar    *data,
0084                                                      gsize            length);
0085 GLIB_AVAILABLE_IN_ALL
0086 gchar                *g_compute_checksum_for_string (GChecksumType    checksum_type,
0087                                                      const gchar     *str,
0088                                                      gssize           length);
0089 
0090 GLIB_AVAILABLE_IN_2_34
0091 gchar                *g_compute_checksum_for_bytes  (GChecksumType    checksum_type,
0092                                                      GBytes          *data);
0093 
0094 G_END_DECLS
0095 
0096 #endif /* __G_CHECKSUM_H__ */