gloox 1.0
|
00001 /* 00002 Copyright (c) 2006-2009 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 #ifndef SHA_H__ 00014 #define SHA_H__ 00015 00016 #include "macros.h" 00017 00018 #include <string> 00019 00020 namespace gloox 00021 { 00022 00029 class GLOOX_API SHA 00030 { 00031 00032 public: 00036 SHA(); 00037 00041 virtual ~SHA(); 00042 00046 void reset(); 00047 00051 void finalize(); 00052 00058 const std::string hex(); 00059 00065 const std::string binary(); 00066 00072 void feed( const unsigned char* data, unsigned length ); 00073 00078 void feed( const std::string& data ); 00079 00080 private: 00081 void process(); 00082 void pad(); 00083 inline unsigned shift( int bits, unsigned word ); 00084 void init(); 00085 00086 unsigned H[5]; 00087 unsigned Length_Low; 00088 unsigned Length_High; 00089 unsigned char Message_Block[64]; 00090 int Message_Block_Index; 00091 bool m_finished; 00092 bool m_corrupted; 00093 00094 }; 00095 00096 } 00097 00098 #endif // SHA_H__