summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/hashing.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/util/hashing.h')
-rw-r--r--src/lib/util/hashing.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/util/hashing.h b/src/lib/util/hashing.h
index 8bb59b9c5cc..08aeec5ac60 100644
--- a/src/lib/util/hashing.h
+++ b/src/lib/util/hashing.h
@@ -44,7 +44,7 @@
#include "osdcore.h"
#include "astring.h"
-#include "zlib.h"
+//#include "zlib.h"
#include "md5.h"
#include "sha1.h"
@@ -62,8 +62,8 @@ struct sha1_t
bool operator==(const sha1_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) == 0; }
bool operator!=(const sha1_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) != 0; }
operator UINT8 *() { return m_raw; }
- const char *as_string(astring &buffer);
- bool from_string(const char *string);
+ bool from_string(const char *string, int length = -1);
+ const char *as_string(astring &buffer) const;
UINT8 m_raw[20];
static const sha1_t null;
};
@@ -113,8 +113,8 @@ struct md5_t
bool operator==(const md5_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) == 0; }
bool operator!=(const md5_t &rhs) const { return memcmp(m_raw, rhs.m_raw, sizeof(m_raw)) != 0; }
operator UINT8 *() { return m_raw; }
- const char *as_string(astring &buffer);
- bool from_string(const char *string);
+ bool from_string(const char *string, int length = -1);
+ const char *as_string(astring &buffer) const;
UINT8 m_raw[16];
static const md5_t null;
};
@@ -161,9 +161,11 @@ protected:
struct crc32_t
{
bool operator==(const crc32_t &rhs) const { return m_raw == rhs.m_raw; }
+ bool operator!=(const crc32_t &rhs) const { return m_raw != rhs.m_raw; }
+ crc32_t &operator=(const UINT32 crc) { m_raw = crc; return *this; }
operator UINT32() const { return m_raw; }
- const char *as_string(astring &buffer);
- bool from_string(const char *string);
+ bool from_string(const char *string, int length = -1);
+ const char *as_string(astring &buffer) const;
UINT32 m_raw;
static const crc32_t null;
};
@@ -179,7 +181,7 @@ public:
void reset() { m_accum.m_raw = 0; }
// append data
- void append(const void *data, UINT32 length) { m_accum.m_raw = crc32(m_accum, reinterpret_cast<const Bytef *>(data), length); }
+ void append(const void *data, UINT32 length);
// finalize and compute the final digest
crc32_t finish() { return m_accum; }
@@ -205,9 +207,11 @@ protected:
struct crc16_t
{
bool operator==(const crc16_t &rhs) const { return m_raw == rhs.m_raw; }
+ bool operator!=(const crc16_t &rhs) const { return m_raw != rhs.m_raw; }
+ crc16_t &operator=(const UINT16 crc) { m_raw = crc; return *this; }
operator UINT16() const { return m_raw; }
- const char *as_string(astring &buffer);
- bool from_string(const char *string);
+ bool from_string(const char *string, int length = -1);
+ const char *as_string(astring &buffer) const;
UINT16 m_raw;
static const crc16_t null;
};