make it possible to disable single-file includes by defining
[platform/upstream/glib.git] / glib / gchecksum.h
1 /* gchecksum.h - data hashing functions
2  *
3  * Copyright (C) 2007  Emmanuele Bassi  <ebassi@gnome.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__G_LIB_H__) && !defined (GLIB_COMPILATION)
22 #error "Only <glib.h> can be included directly."
23 #endif
24
25 #ifndef __G_CHECKSUM_H__
26 #define __G_CHECKSUM_H__
27
28 #include <glib/gtypes.h>
29
30 G_BEGIN_DECLS
31
32 /**
33  * GChecksumType:
34  * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm
35  * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm
36  * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm
37  *
38  * The hashing algorithm to be used by #GChecksum when performing the
39  * digest of some data.
40  *
41  * Note that the #GChecksumType enumeration may be extended at a later 
42  * date to include new hashing algorithm types. 
43  *
44  * Since: 2.16
45  */
46 typedef enum {
47   G_CHECKSUM_MD5,
48   G_CHECKSUM_SHA1,
49   G_CHECKSUM_SHA256
50 } GChecksumType;
51
52 typedef struct _GChecksum       GChecksum;
53
54 gssize                g_checksum_type_get_length (GChecksumType checksum_type);
55
56 GChecksum *           g_checksum_new        (GChecksumType     checksum_type);
57 GChecksum *           g_checksum_copy       (const GChecksum  *checksum);
58 void                  g_checksum_free       (GChecksum        *checksum);
59 void                  g_checksum_update     (GChecksum        *checksum,
60                                              const guchar     *data,
61                                              gssize            length);
62 G_CONST_RETURN gchar *g_checksum_get_string (GChecksum        *checksum);
63 void                  g_checksum_get_digest (GChecksum        *checksum,
64                                              guint8           *buffer,
65                                              gsize            *digest_len);
66
67 gchar *g_compute_checksum_for_data   (GChecksumType  checksum_type,
68                                       const guchar  *data,
69                                       gsize          length);
70 gchar *g_compute_checksum_for_string (GChecksumType  checksum_type,
71                                       const gchar   *str,
72                                       gssize         length);
73
74 G_END_DECLS
75
76 #endif /* __G_CHECKSUM_H__ */