]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/osrf_digest.h
Add a stream parser for JSON, and a format_json utility
[OpenSRF.git] / include / opensrf / osrf_digest.h
1 /*
2  *  This program is free software; you can redistribute it and/or modify
3  *  it under the terms of the GNU General Public License as published by
4  *  the Free Software Foundation; either version 2 of the License, or
5  *  (at your option) any later version.
6  *
7  *  This program is distributed in the hope that it will be useful,
8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *  GNU General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * Copyright (C) 2009 Equinox Software Inc.
17  */
18
19 /**
20         @file osrf_digest.h
21         @brief Header for digest functions.
22
23         In each case, the input is a nul-terminated character string.  The result is returned
24         in a structure provided by the calling code, both in a binary buffer and in a
25         nul-terminated string of hex characters encoding the same value.
26 */
27
28 #ifndef OSRF_DIGEST_H
29 #define OSRF_DIGEST_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36         @brief Contains an SHA1 digest.
37 */
38 typedef struct {
39         unsigned char binary[ 20 ];  /**< Binary SHA1 digest. */
40         char hex[ 41 ];              /**< Same digest, in the form of a hex string. */
41 } osrfSHA1Buffer;
42
43 /**
44         @brief Contains an MD5 digest.
45 */
46 typedef struct {
47         unsigned char binary[ 16 ];  /**< Binary MD5 digest. */
48         char hex[ 33 ];              /**< Same digest, in the form of a hex string. */
49 } osrfMD5Buffer;
50
51 void osrf_sha1_digest( osrfSHA1Buffer* result, const char *str );
52
53 void osrf_sha1_digest_fmt( osrfSHA1Buffer* result, const char* str, ... );
54
55 void osrf_md5_digest( osrfMD5Buffer* result, const char *str );
56
57 void osrf_md5_digest_fmt( osrfMD5Buffer* result, const char* str, ... );
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif