MD5.h

Go to the documentation of this file.
00001 /* $Id: MD5.h 571 2007-12-02 08:34:30Z mindstorm2600 $ */
00002 /*
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016  */
00017 
00018 #ifndef __XVR2_TEXT_MD5_H__
00019 #define __XVR2_TEXT_MD5_H__
00020 #include<xvr2/String.h>
00021 #include<xvr2/Buffer.h>
00022 #include<xvr2/CoreExceptions.h>
00023 #include<xvr2/Text/ChecksumExceptions.h>
00024 
00025 namespace xvr2 {
00026         namespace Text {
00027 
00028                 struct MD5Context {
00029                         UInt32 buf[4];
00030                         UInt32 bits[2];
00031                         UInt8 in[64];
00032                 };
00033 
00034                 class MD5Hash : public xvr2::Object {
00035                         protected:
00036                                 UInt8 data[16];
00037                         public:
00038                                 MD5Hash();
00039                                 MD5Hash(UInt8 *_data);
00040                                 MD5Hash(const MD5Hash &hash);
00041                                 MD5Hash(const String &_data);
00042                                 UInt8 operator[](unsigned int idx);
00043                                 virtual std::string toString();
00044                 };
00045 
00046                 class MD5 : public xvr2::Object {
00047                         protected:
00048                                 MD5Context ctx;
00049                                 void init();
00050                                 void update(unsigned char const *buf, unsigned len);
00051                                 void final(UInt8 *_digest);
00052                         public:
00053                                 MD5();
00054                                 MD5(const String &str);
00055                                 MD5Hash digest();
00056                                 const MD5 &digest(MD5Hash &hash);
00057                                 const MD5 &operator<<(const Buffer &b);
00058                                 const MD5 &operator<<(const String &s);
00059                                 static MD5Hash digest(const String &str);
00060                                 static MD5Hash digest(const String &str, MD5Hash &hash);
00061                 };
00062                 
00063         };
00064 
00065 };
00066 
00067 #endif
00068 

Generated on Fri Jun 20 22:55:48 2008 for X-VR2 SDK by  doxygen 1.5.5