| Revision 217,
1.1 KB
checked in by martin, 6 years ago
(diff) |
|
Set svn:eol-style as appropriate for all files
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | // -------------------------------------------------------------------------- |
|---|
| 2 | // |
|---|
| 3 | // File |
|---|
| 4 | // Name: MD5Digest.h |
|---|
| 5 | // Purpose: Simple interface for creating MD5 digests |
|---|
| 6 | // Created: 8/12/03 |
|---|
| 7 | // |
|---|
| 8 | // -------------------------------------------------------------------------- |
|---|
| 9 | |
|---|
| 10 | #ifndef MD5DIGEST_H |
|---|
| 11 | #define MD5DIGEST_H |
|---|
| 12 | |
|---|
| 13 | #include <openssl/md5.h> |
|---|
| 14 | #include <string> |
|---|
| 15 | |
|---|
| 16 | // -------------------------------------------------------------------------- |
|---|
| 17 | // |
|---|
| 18 | // Function |
|---|
| 19 | // Name: MD5Digest |
|---|
| 20 | // Purpose: Simple interface for creating MD5 digests |
|---|
| 21 | // Created: 8/12/03 |
|---|
| 22 | // |
|---|
| 23 | // -------------------------------------------------------------------------- |
|---|
| 24 | class MD5Digest |
|---|
| 25 | { |
|---|
| 26 | public: |
|---|
| 27 | MD5Digest(); |
|---|
| 28 | virtual ~MD5Digest(); |
|---|
| 29 | |
|---|
| 30 | void Add(const std::string &rString); |
|---|
| 31 | void Add(const void *pData, int Length); |
|---|
| 32 | |
|---|
| 33 | void Finish(); |
|---|
| 34 | |
|---|
| 35 | std::string DigestAsString(); |
|---|
| 36 | uint8_t *DigestAsData(int *pLength = 0) |
|---|
| 37 | { |
|---|
| 38 | if(pLength) *pLength = sizeof(mDigest); |
|---|
| 39 | return mDigest; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | enum |
|---|
| 43 | { |
|---|
| 44 | DigestLength = MD5_DIGEST_LENGTH |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | int CopyDigestTo(uint8_t *to); |
|---|
| 48 | |
|---|
| 49 | bool DigestMatches(uint8_t *pCompareWith) const; |
|---|
| 50 | |
|---|
| 51 | private: |
|---|
| 52 | MD5_CTX md5; |
|---|
| 53 | uint8_t mDigest[MD5_DIGEST_LENGTH]; |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | #endif // MD5DIGEST_H |
|---|
| 57 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.