cctools
md5.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2008- The University of Notre Dame
3 This software is distributed under the GNU General Public License.
4 See the file COPYING for details.
5 */
6 
7 #ifndef MD5_H
8 #define MD5_H
9 
10 #include <stdint.h>
11 #include <stdlib.h>
12 
13 #define md5_init cctools_md5_init
14 #define md5_update cctools_md5_update
15 #define md5_final cctools_md5_final
16 #define md5_buffer cctools_md5_buffer
17 #define md5_file cctools_md5_file
18 #define md5_string cctools_md5_string
19 
24 #define MD5_DIGEST_LENGTH 16
25 #define MD5_DIGEST_LENGTH_HEX (MD5_DIGEST_LENGTH<<1)
26 
27 typedef struct {
28  uint32_t state[4];
29  uint32_t count[2];
30  uint8_t buffer[64];
32 
33 void md5_init(md5_context_t * ctx);
34 void md5_update(md5_context_t * ctx, const void *, size_t);
35 void md5_final(unsigned char digest[MD5_DIGEST_LENGTH], md5_context_t * ctx);
36 
45 void md5_buffer(const void *buffer, size_t length, unsigned char digest[MD5_DIGEST_LENGTH]);
46 
55 int md5_file(const char *filename, unsigned char digest[MD5_DIGEST_LENGTH]);
56 
62 const char *md5_string(unsigned char digest[MD5_DIGEST_LENGTH]);
63 
64 /* md5_cal calculates the md5 checksum of string s.
65  * @param s: a string pointer
66  * return the md5 checksum of s on success, return NULL on failure.
67  * The caller should free the returned string.
68  */
69 char *md5_cal(const char *s);
70 
71 #endif
Definition: md5.h:27
const char * md5_string(unsigned char digest[MD5_DIGEST_LENGTH])
Convert an MD5 digest into a printable string.
void md5_buffer(const void *buffer, size_t length, unsigned char digest[MD5_DIGEST_LENGTH])
Checksum a memory buffer.
Definition: buffer.h:26
int md5_file(const char *filename, unsigned char digest[MD5_DIGEST_LENGTH])
Checksum a local file.