gloox  0.9.9.12
sha.h
1 /*
2  Copyright (c) 2006-2008 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 #ifndef SHA_H__
14 #define SHA_H__
15 
16 #include "macros.h"
17 
18 #include <string>
19 
20 namespace gloox
21 {
22 
29  class GLOOX_API SHA
30  {
31 
32  public:
36  SHA();
37 
41  virtual ~SHA();
42 
46  void reset();
47 
51  void finalize();
52 
58  const std::string hex();
59 
65  void feed( const unsigned char *data, unsigned length );
66 
71  void feed( const std::string& data );
72 
73  private:
74  void process();
75  void pad();
76  inline unsigned shift( int bits, unsigned word );
77  void init();
78 
79  unsigned H[5];
80  unsigned Length_Low;
81  unsigned Length_High;
82  unsigned char Message_Block[64];
83  int Message_Block_Index;
84  bool m_finished;
85  bool m_corrupted;
86 
87  };
88 
89 }
90 
91 #endif // SHA_H__