0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
md5.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
30 #ifndef _MD5_H
31 #define _MD5_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
44 typedef struct {
45  unsigned long total[2];
46  unsigned long state[4];
47  unsigned char buffer[64];
48 } md5_context;
49 
54 void md5_starts(md5_context *ctx);
55 
62 void md5_update(md5_context *ctx, const unsigned char *input, int ilen);
63 
69 void md5_finish(md5_context *ctx, unsigned char output[16]);
70 
77 void md5_csum(const unsigned char *input, int ilen, unsigned char output[16]);
78 
85 int md5_file(const char *path, unsigned char output[16]);
86 
95 void md5_hmac(unsigned char *key, int keylen,
96  const unsigned char *input, int ilen,
97  unsigned char output[16]);
98 
103 int md5_self_test(void);
104 
112 void md5_hex(const void *input, size_t ilen, char output[33]);
113 
119 void md5_string(const char *input, char output[33]);
120 
125 int64_t md5_hash(const char *input);
126 
135 void md5_trunc_modified_base64(const char *input, char output[17]);
136 
144 void digest_to_trunc_modified_base64(const char digest[16], char output[17]);
145 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif /* md5.h */
void md5_hmac(unsigned char *key, int keylen, const unsigned char *input, int ilen, unsigned char output[16])
Calculates a "Hashed MAC" of an input buffer combined with a secret key.
Definition: md5.cc:325
int64_t md5_hash(const char *input)
Returns a 64-bit hash checksum of a null terminated input buffer.
Definition: md5.cc:388
int md5_file(const char *path, unsigned char output[16])
Convenience function to calculate the MD5 sum of a file.
void digest_to_trunc_modified_base64(const char digest[16], char output[17])
Get the modified base64 encoded string of a 16 byte message digest see http://en.wikipedia.org/wiki/Base64#URL_applications for more information.
Definition: md5.cc:402
void md5_trunc_modified_base64(const char *input, char output[17])
Get the modified base64 encoded string of the first 12 Bytes of the 16 Byte MD5 code of a null termin...
Definition: md5.cc:425
void md5_update(md5_context *ctx, const unsigned char *input, int ilen)
Adds data to the MD5 process buffer.
Definition: md5.cc:208
void md5_starts(md5_context *ctx)
Initialize and setup a MD5 context structure.
Definition: md5.cc:71
void md5_csum(const unsigned char *input, int ilen, unsigned char output[16])
Convenience function to calculate the MD5 sum of an input buffer.
Definition: md5.cc:312
void md5_string(const char *input, char output[33])
Calculates the hex string of MD5 of null terminated input.
Definition: md5.cc:384
MD5 context structure; this structure is used to store the internal state of the md5 algorithm...
Definition: md5.h:44
void md5_finish(md5_context *ctx, unsigned char output[16])
Retrieve the final MD5 digest.
Definition: md5.cc:260
int md5_self_test(void)
Runs a self test.
Definition: md5.cc:476
void md5_hex(const void *input, size_t ilen, char output[33])
Convenience function to calculate the MD5 sum of an input buffer; returns string with the MD5 encoded...
Definition: md5.cc:366