00001 // 00002 // CascadeMD5.h - header file for class CascadeMD5 00003 // 00004 // Copyright (c) 2004, Roku, LLC. All rights reserved. 00005 // 00008 00009 #ifndef _ROKU_INCLUDE_CASCADE_UTIL_CASCADEMD5_H 00010 #define _ROKU_INCLUDE_CASCADE_UTIL_CASCADEMD5_H 00011 00012 #include <cascade/CascadeObject.h> 00013 #include <cascade/util/CascadeString.h> 00014 00027 class CascadeMD5 : public CascadeObject 00028 { 00029 public: 00030 CascadeMD5(); 00031 virtual ~CascadeMD5(); 00032 00033 public: 00034 void Begin(); 00035 // starts a new MD5 checksum calculation 00036 void Calculate(const void * pData, u32 nDataLen); 00037 // Calculates the MD5 checksum of nDataLen bytes from *pData 00038 // Calculate() may be called consecutively. 00039 void End(); 00040 // End() ends the MD5 checksum calculation. 00041 00042 void GetResult(u8 * pDigestToSet); 00043 // GetResult sets *pDigestToSet with the 16 byte result of the md5 00044 // calculation (called the digest). pDigestToSet must point to 00045 // 16 consecutive bytes. The digest result is valid only after 00046 // a successful Begin, Calculate, End sequence and is valid until 00047 // the next call to Begin(). 00048 00049 void GetResult(CascadeString & digestStringToSet, bool bUpperCase = false); 00050 // This version of GetResult() sets digestStringToSet with 00051 // an ascii representation of the digest result suitable 00052 // for printing or comparing with existing md5 strings. 00053 // if bUpperCase is set to true the hex digits 'A' - 'F' will 00054 // be placed as upper case ascii characters in the string. 00055 // The default is to put lower case characters in the string. 00056 00057 private: 00058 u32 m_opaque[22]; 00059 u8 m_digest[16]; 00060 }; 00061 00062 #endif // #ifndef _ROKU_INCLUDE_CASCADE_UTIL_CASCADEMD5_H 00063 00065 // LOG 00067 // 27-Apr-04 dwoodward created 00068