-
Notifications
You must be signed in to change notification settings - Fork 8
/
md5.h
36 lines (29 loc) · 1.2 KB
/
md5.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*********************************************************************
* Filename: md5.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding MD5 implementation.
*********************************************************************/
#ifndef MD5_H
#define MD5_H
/*************************** HEADER FILES ***************************/
#include <cstddef>
#include <cstdint>
/****************************** MACROS ******************************/
constexpr int MD5_BLOCK_SIZE = 16; // MD5 outputs a 16 byte digest
/**************************** DATA TYPES ****************************/
using BYTE = unsigned char; // 8-bit byte
using WORD = unsigned int; // 32-bit word, change to "long" for 16-bit machines
using MD5_CTX = struct {
BYTE data[64];
WORD datalen;
std::uint64_t bitlen;
WORD state[4];
};
/*********************** FUNCTION DECLARATIONS **********************/
void md5_init(MD5_CTX *ctx);
void md5_update(MD5_CTX *ctx, const BYTE data[], size_t len);
void md5_final(MD5_CTX *ctx, BYTE hash[]);
void md5_file(const char filename[], char hashout[33]);
#endif // MD5_H