Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_CSUTIL_DIGEST_H__
00020 #define __CS_CSUTIL_DIGEST_H__
00021
00026 #include "csutil/csstring.h"
00027 #include "csutil/hash.h"
00028
00029 namespace CS
00030 {
00031 namespace Utility
00032 {
00033 namespace Checksum
00034 {
00036 struct CS_CRYSTALSPACE_EXPORT DigestFormat
00037 {
00039 static csString HexString (const uint8* data, uint size);
00041 static csString HEXString (const uint8* data, uint size);
00042 };
00043
00047 template<uint Size>
00048 class Digest : protected DigestFormat
00049 {
00050 public:
00051 enum { DigestLen = Size };
00053 uint8 data[DigestLen];
00055 csString HexString() const
00056 { return DigestFormat::HexString (data, Size); }
00058 csString HEXString() const
00059 { return DigestFormat::HEXString (data, Size); }
00060
00061 bool operator==(const Digest& other) const
00062 { return memcmp (data, other.data, sizeof (data)) == 0; }
00063 bool operator!=(const Digest& other) const
00064 { return memcmp (data, other.data, sizeof (data)) != 0; }
00065 };
00066 }
00067 }
00068 }
00069
00070 template<uint Size>
00071 class csHashComputer<CS::Utility::Checksum::Digest<Size> > :
00072 public csHashComputerStruct<CS::Utility::Checksum::Digest<Size> > {};
00073
00074 template<uint Size>
00075 class csComparator<CS::Utility::Checksum::Digest<Size> > :
00076 public csComparatorStruct<CS::Utility::Checksum::Digest<Size> > {};
00077
00078 #endif // __CS_CSUTIL_DIGEST_H__