72
72
#ifndef md5_INCLUDED
74
75
#include <string.h>
76
79
/* Define the state of the MD5 Algorithm. */
79
80
typedef unsigned int md5_word_t;
80
#define CHECKSUM_VALUE_SIZE 16
83
u_char val[CHECKSUM_VALUE_SIZE];
82
#define MD5_CHECKSUM_SIZE CHECKSUM_VALUE_SIZE
83
#define MD5_CHECKSUM_STRING_SIZE (CHECKSUM_VALUE_SIZE * 2 + 1)
88
87
struct md5_state_s {
89
md5_word_t count[2]; /* message length in bits, lsw first */
90
md5_word_t abcd[4]; /* digest buffer */
91
u_char buf[64]; /* accumulate block */
88
md5_word_t count[2]; /* message length in bits, lsw first */
89
md5_word_t abcd[4]; /* digest buffer */
90
u_char buf[64]; /* accumulate block */
93
u_char digest[MD5_CHECKSUM_SIZE];
94
char digest_cstr[MD5_CHECKSUM_STRING_SIZE];
94
96
void md5_process(const u_char *data /*[64]*/);
104
106
/* Append a string to the message. */
105
107
void md5_append(const u_char *data, int nbytes);
106
void md5_append(const char *data)
109
void md5_append(const char *data) {
108
110
md5_append((const u_char *) data, strlen(data));
112
113
/* Finish the message and return the digest. */
113
void md5_digest(Md5Digest *digest);
115
// Returns the raw bin digest.
116
const u_char *md5_get_digest() {
122
// Returns the bin/hex digest.
123
void md5_get_digest(Md5Digest *d) {
127
memcpy(d->val, digest, CHECKSUM_VALUE_SIZE);
130
// Returns the bin/hex digest.
131
const char *md5_get_digest_cstr() {
117
139
#endif /* md5_INCLUDED */