CHashKey Struct Reference

#include <sha1.h>


Public Member Functions

 CHashKey (const std::string &str)
 CHashKey (const unsigned char Message_Digest[20])
 CHashKey ()
bool operator== (const CHashKey &v) const
void serial (NLMISC::IStream &stream)
std::string toString () const

Data Fields

std::string HashKeyString


Constructor & Destructor Documentation

CHashKey::CHashKey  )  [inline]
 

Definition at line 43 of file sha1.h.

00043 { }

CHashKey::CHashKey const unsigned char  Message_Digest[20]  )  [inline]
 

Definition at line 45 of file sha1.h.

References HashKeyString, and sint.

00046         {
00047                 HashKeyString = "";
00048                 for(sint i = 0; i < 20 ; ++i)
00049                 {
00050                         HashKeyString += Message_Digest[i];
00051                 }
00052         }

CHashKey::CHashKey const std::string &  str  )  [inline]
 

Definition at line 55 of file sha1.h.

References HashKeyString, nlwarning, uint, and uint8.

00056         {
00057                 if (str.size() == 20)
00058                 {
00059                         HashKeyString = str;
00060                 }
00061                 else if (str.size() == 40)
00062                 {
00063                         HashKeyString = "";
00064                         for(uint i = 0; i < str.size(); i+=2)
00065                         {
00066                                 uint8 val;
00067                                 if (isdigit(str[i+0]))
00068                                         val = str[i+0]-'0';
00069                                 else
00070                                         val = 10+tolower(str[i+0])-'a';
00071                                 val *= 16;
00072                                 if (isdigit(str[i+1]))
00073                                         val += str[i+1]-'0';
00074                                 else
00075                                         val += 10+tolower(str[i+1])-'a';
00076 
00077                                 HashKeyString += val;
00078                         }
00079                 }
00080                 else
00081                 {
00082                         nlwarning ("SHA: Bad hash key format");
00083                 }
00084         }


Member Function Documentation

bool CHashKey::operator== const CHashKey v  )  const [inline]
 

Definition at line 103 of file sha1.h.

References HashKeyString, and v.

00104         {
00105                 return HashKeyString == v.HashKeyString;
00106         }

void CHashKey::serial NLMISC::IStream stream  )  [inline]
 

Definition at line 98 of file sha1.h.

References HashKeyString, and NLMISC::IStream::serial().

00099         {
00100                 stream.serial (HashKeyString);
00101         }

std::string CHashKey::toString  )  const [inline]
 

Definition at line 87 of file sha1.h.

References HashKeyString, NLMISC::toString(), uint, and uint8.

00088         {
00089                 std::string str;
00090                 for (uint i = 0; i < HashKeyString.size(); i++)
00091                 {
00092                         str += NLMISC::toString("%02X", (uint8)(HashKeyString[i]));
00093                 }
00094                 return str;
00095         }


Field Documentation

std::string CHashKey::HashKeyString
 

Definition at line 109 of file sha1.h.

Referenced by CHashKey(), operator<(), operator==(), serial(), and toString().


The documentation for this struct was generated from the following file:
Generated on Tue Mar 16 06:43:53 2004 for NeL by doxygen 1.3.6