blob: 1be01ea93829cd81ab4edec65860a1fd575dd653 (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// --------------------------------------------------------------------------
//
// File
// Name: MD5Digest.h
// Purpose: Simple interface for creating MD5 digests
// Created: 8/12/03
//
// --------------------------------------------------------------------------
#ifndef MD5DIGEST_H
#define MD5DIGEST_H
#include <openssl/md5.h>
#include <string>
// --------------------------------------------------------------------------
//
// Function
// Name: MD5Digest
// Purpose: Simple interface for creating MD5 digests
// Created: 8/12/03
//
// --------------------------------------------------------------------------
class MD5Digest
{
public:
MD5Digest();
virtual ~MD5Digest();
void Add(const std::string &rString);
void Add(const void *pData, int Length);
void Finish();
std::string DigestAsString();
uint8_t *DigestAsData(int *pLength = 0)
{
if(pLength) *pLength = sizeof(mDigest);
return mDigest;
}
enum
{
DigestLength = MD5_DIGEST_LENGTH
};
int CopyDigestTo(uint8_t *to);
bool DigestMatches(uint8_t *pCompareWith) const;
private:
MD5_CTX md5;
uint8_t mDigest[MD5_DIGEST_LENGTH];
};
#endif // MD5DIGEST_H
|