![]() |
|
|||
File indexing completed on 2025-08-03 08:20:53
0001 #ifndef __PHMD5VALUE_H__ 0002 #define __PHMD5VALUE_H__ 0003 0004 /** 0005 This is a simple class maintaining a md5 checksum value for us. 0006 It is geared towards the md5 value from files, and accepts 0007 filenames, a FILE * in its constructor. 0008 0009 It is made so that it gives the same result as the UNIX md5sum command. 0010 0011 I used and modified the md5_stream routine in the GNU textutils package 0012 (which has a larger scope and doesn't compile easily with non-GNU 0013 compilers). 0014 0015 I used the "MD5 message digest library" written by L. Peter Deutsch 0016 (ghost@aladdin.com) to actually compute the MD5 sums. This package 0017 compiles happily on all platforms, including Sun/Solaris w/ native 0018 compiler. 0019 0020 */ 0021 0022 #include "PHmd5Utils.h" 0023 0024 #define PHMD5DIGESTLENGTH 16 0025 #include "event_io.h" 0026 0027 0028 #define WINDOWSEXPORT 0029 0030 0031 #ifndef __CINT__ 0032 class WINDOWSEXPORT PHmd5Value { 0033 #else 0034 class PHmd5Value { 0035 #endif 0036 public: 0037 /// construct an "empty" object 0038 PHmd5Value(); 0039 0040 /// the copy constructor 0041 PHmd5Value(const PHmd5Value &); 0042 0043 /// give an open file pointer to gte the checksum of that file 0044 PHmd5Value(FILE *fp); 0045 0046 /// give a filename to get the MD5 sum of that file 0047 PHmd5Value(const char *filename); 0048 0049 // and the destructor 0050 ~PHmd5Value(); 0051 0052 /// The Status() is 0 if the md5 could be computed alright. 0053 int Status() const; 0054 0055 /// overload the == operator to tell if two MD5 sums are equal 0056 int operator== (const PHmd5Value &) const; 0057 0058 /// copy the digest to the "digest" parameter 0059 int getMD5(unsigned char * digest) const; 0060 0061 /// set a new digest value from the argument 0062 int setMD5(const unsigned char * digest); 0063 0064 /// if we change the file, this allows to update the MD5 sum 0065 int setFileMD5(const char * filename); 0066 0067 /// this is for convenience -- once we digest the file, we might 0068 /// as well remember its size to get back at it later. 0069 int FileSize() const; 0070 0071 /// define the ostream >> operator 0072 friend OSTREAM & operator<< ( OSTREAM &, const PHmd5Value &); 0073 0074 protected: 0075 unsigned char theDigest[PHMD5DIGESTLENGTH]; 0076 int isNotValid; // here we indicate that an actual value has been set alright (0); 0077 int filesize; 0078 }; 0079 0080 0081 0082 #endif /* __PHMD5VALUE_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |