|
@@ -28,18 +28,18 @@ template<int N>
|
|
|
class HashSumValue
|
|
class HashSumValue
|
|
|
{
|
|
{
|
|
|
unsigned char Sum[N/8];
|
|
unsigned char Sum[N/8];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public:
|
|
public:
|
|
|
|
|
|
|
|
// Accessors
|
|
// Accessors
|
|
|
bool operator ==(const HashSumValue &rhs) const
|
|
bool operator ==(const HashSumValue &rhs) const
|
|
|
{
|
|
{
|
|
|
return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
|
|
return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
bool operator !=(const HashSumValue &rhs) const
|
|
bool operator !=(const HashSumValue &rhs) const
|
|
|
{
|
|
{
|
|
|
return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0;
|
|
return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0;
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
std::string Value() const
|
|
std::string Value() const
|
|
|
{
|
|
{
|
|
@@ -49,7 +49,7 @@ class HashSumValue
|
|
|
};
|
|
};
|
|
|
char Result[((N/8)*2)+1];
|
|
char Result[((N/8)*2)+1];
|
|
|
Result[(N/8)*2] = 0;
|
|
Result[(N/8)*2] = 0;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Convert each char into two letters
|
|
// Convert each char into two letters
|
|
|
int J = 0;
|
|
int J = 0;
|
|
|
int I = 0;
|
|
int I = 0;
|
|
@@ -59,31 +59,31 @@ class HashSumValue
|
|
|
Result[I + 1] = Conv[Sum[J] & 0xF];
|
|
Result[I + 1] = Conv[Sum[J] & 0xF];
|
|
|
}
|
|
}
|
|
|
return std::string(Result);
|
|
return std::string(Result);
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
inline void Value(unsigned char S[N/8])
|
|
inline void Value(unsigned char S[N/8])
|
|
|
{
|
|
{
|
|
|
- for (int I = 0; I != sizeof(Sum); I++)
|
|
|
|
|
|
|
+ for (int I = 0; I != sizeof(Sum); ++I)
|
|
|
S[I] = Sum[I];
|
|
S[I] = Sum[I];
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- inline operator std::string() const
|
|
|
|
|
|
|
+ inline operator std::string() const
|
|
|
{
|
|
{
|
|
|
return Value();
|
|
return Value();
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- bool Set(std::string Str)
|
|
|
|
|
|
|
+ bool Set(std::string Str)
|
|
|
{
|
|
{
|
|
|
return Hex2Num(Str,Sum,sizeof(Sum));
|
|
return Hex2Num(Str,Sum,sizeof(Sum));
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- inline void Set(unsigned char S[N/8])
|
|
|
|
|
|
|
+ inline void Set(unsigned char S[N/8])
|
|
|
{
|
|
{
|
|
|
- for (int I = 0; I != sizeof(Sum); I++)
|
|
|
|
|
|
|
+ for (int I = 0; I != sizeof(Sum); ++I)
|
|
|
Sum[I] = S[I];
|
|
Sum[I] = S[I];
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- HashSumValue(std::string Str)
|
|
|
|
|
|
|
+ HashSumValue(std::string Str)
|
|
|
{
|
|
{
|
|
|
memset(Sum,0,sizeof(Sum));
|
|
memset(Sum,0,sizeof(Sum));
|
|
|
Set(Str);
|
|
Set(Str);
|
|
@@ -99,17 +99,17 @@ class SummationImplementation
|
|
|
public:
|
|
public:
|
|
|
virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
|
|
virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
|
|
|
inline bool Add(const char *inbuf, unsigned long long const inlen)
|
|
inline bool Add(const char *inbuf, unsigned long long const inlen)
|
|
|
- { return Add((unsigned char *)inbuf, inlen); };
|
|
|
|
|
|
|
+ { return Add((const unsigned char *)inbuf, inlen); }
|
|
|
|
|
|
|
|
inline bool Add(const unsigned char *Data)
|
|
inline bool Add(const unsigned char *Data)
|
|
|
- { return Add(Data, strlen((const char *)Data)); };
|
|
|
|
|
|
|
+ { return Add(Data, strlen((const char *)Data)); }
|
|
|
inline bool Add(const char *Data)
|
|
inline bool Add(const char *Data)
|
|
|
- { return Add((const unsigned char *)Data, strlen((const char *)Data)); };
|
|
|
|
|
|
|
+ { return Add((const unsigned char *)Data, strlen((const char *)Data)); }
|
|
|
|
|
|
|
|
inline bool Add(const unsigned char *Beg, const unsigned char *End)
|
|
inline bool Add(const unsigned char *Beg, const unsigned char *End)
|
|
|
- { return Add(Beg, End - Beg); };
|
|
|
|
|
|
|
+ { return Add(Beg, End - Beg); }
|
|
|
inline bool Add(const char *Beg, const char *End)
|
|
inline bool Add(const char *Beg, const char *End)
|
|
|
- { return Add((const unsigned char *)Beg, End - Beg); };
|
|
|
|
|
|
|
+ { return Add((const unsigned char *)Beg, End - Beg); }
|
|
|
|
|
|
|
|
bool AddFD(int Fd, unsigned long long Size = 0);
|
|
bool AddFD(int Fd, unsigned long long Size = 0);
|
|
|
bool AddFD(FileFd &Fd, unsigned long long Size = 0);
|
|
bool AddFD(FileFd &Fd, unsigned long long Size = 0);
|