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 Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2.1 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 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public License |
16 | * along with this library; if not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | #ifndef __G_CHECKSUM_H__ |
20 | #define __G_CHECKSUM_H__ |
21 | |
22 | #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) |
23 | #error "Only <glib.h> can be included directly." |
24 | #endif |
25 | |
26 | #include <glib/gtypes.h> |
27 | #include <glib/gbytes.h> |
28 | |
29 | G_BEGIN_DECLS |
30 | |
31 | /** |
32 | * GChecksumType: |
33 | * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm |
34 | * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm |
35 | * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm |
36 | * @G_CHECKSUM_SHA384: Use the SHA-384 hashing algorithm (Since: 2.51) |
37 | * @G_CHECKSUM_SHA512: Use the SHA-512 hashing algorithm (Since: 2.36) |
38 | * |
39 | * The hashing algorithm to be used by #GChecksum when performing the |
40 | * digest of some data. |
41 | * |
42 | * Note that the #GChecksumType enumeration may be extended at a later |
43 | * date to include new hashing algorithm types. |
44 | * |
45 | * Since: 2.16 |
46 | */ |
47 | typedef enum { |
48 | G_CHECKSUM_MD5, |
49 | G_CHECKSUM_SHA1, |
50 | G_CHECKSUM_SHA256, |
51 | G_CHECKSUM_SHA512, |
52 | G_CHECKSUM_SHA384 |
53 | } GChecksumType; |
54 | |
55 | /** |
56 | * GChecksum: |
57 | * |
58 | * An opaque structure representing a checksumming operation. |
59 | * To create a new GChecksum, use g_checksum_new(). To free |
60 | * a GChecksum, use g_checksum_free(). |
61 | * |
62 | * Since: 2.16 |
63 | */ |
64 | typedef struct _GChecksum GChecksum; |
65 | |
66 | GLIB_AVAILABLE_IN_ALL |
67 | gssize g_checksum_type_get_length (GChecksumType checksum_type); |
68 | |
69 | GLIB_AVAILABLE_IN_ALL |
70 | GChecksum * g_checksum_new (GChecksumType checksum_type); |
71 | GLIB_AVAILABLE_IN_ALL |
72 | void g_checksum_reset (GChecksum *checksum); |
73 | GLIB_AVAILABLE_IN_ALL |
74 | GChecksum * g_checksum_copy (const GChecksum *checksum); |
75 | GLIB_AVAILABLE_IN_ALL |
76 | void g_checksum_free (GChecksum *checksum); |
77 | GLIB_AVAILABLE_IN_ALL |
78 | void g_checksum_update (GChecksum *checksum, |
79 | const guchar *data, |
80 | gssize length); |
81 | GLIB_AVAILABLE_IN_ALL |
82 | const gchar * g_checksum_get_string (GChecksum *checksum); |
83 | GLIB_AVAILABLE_IN_ALL |
84 | void g_checksum_get_digest (GChecksum *checksum, |
85 | guint8 *buffer, |
86 | gsize *digest_len); |
87 | |
88 | GLIB_AVAILABLE_IN_ALL |
89 | gchar *g_compute_checksum_for_data (GChecksumType checksum_type, |
90 | const guchar *data, |
91 | gsize length); |
92 | GLIB_AVAILABLE_IN_ALL |
93 | gchar *g_compute_checksum_for_string (GChecksumType checksum_type, |
94 | const gchar *str, |
95 | gssize length); |
96 | |
97 | GLIB_AVAILABLE_IN_2_34 |
98 | gchar *g_compute_checksum_for_bytes (GChecksumType checksum_type, |
99 | GBytes *data); |
100 | |
101 | G_END_DECLS |
102 | |
103 | #endif /* __G_CHECKSUM_H__ */ |
104 | |