csutil/sha256.h
00001 /* 00002 Crystal Space utility library: SHA256 class 00003 Original C code written by Jesse Kornblum (see related source) 00004 Adapted for Crystal Space by Stefano Angeleri <weltall2@gmail.com> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public 00017 License along with this library; if not, write to the Free 00018 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 00020 */ 00021 00022 #ifndef _CSSHA256_H 00023 #define _CSSHA256_H 00024 00025 #include "csextern.h" 00026 #include "csutil/csstring.h" 00027 #include "csutil/digest.h" 00028 #include "csutil/hash.h" 00029 00030 namespace CS 00031 { 00032 namespace Utility 00033 { 00034 namespace Checksum 00035 { 00044 class CS_CRYSTALSPACE_EXPORT SHA256 00045 { 00047 00048 uint32 total[2]; 00049 uint32 state[8]; 00050 uint8 buffer[64]; 00052 00057 void Process (const uint8 data[64]); 00059 void AppendInternal (const uint8* input, uint32 length); 00064 void Finish (uint8 digest[32]); 00065 public: 00067 typedef CS::Utility::Checksum::Digest<32> Digest; 00068 00069 SHA256 (); 00070 00076 void Append (const uint8* input, size_t length); 00077 00084 Digest Finish (); 00085 00087 static Digest Encode(csString const&); 00089 static Digest Encode(const char*); 00091 static Digest Encode(const void*, size_t nbytes); 00092 }; 00093 00094 }//namespace Checksum 00095 }//namespace Utility 00096 }//namespace CS 00097 00098 00099 #endif // _CSSHA256_H
Generated for Crystal Space 2.0 by doxygen 1.6.1