1 /* 2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SHA_256_H 6 #define _SHA_256_H 7 8 9 #include <SupportDefs.h> 10 11 12 #define SHA_DIGEST_LENGTH 32 13 14 namespace BPrivate { 15 16 17 class SHA256 { 18 public: 19 SHA256(); 20 ~SHA256(); 21 22 void Init(); 23 void Update(const void* buffer, size_t size); 24 const uint8* Digest(); DigestLength()25 size_t DigestLength() const 26 { return SHA_DIGEST_LENGTH; } 27 28 private: 29 void _ProcessChunk(); 30 31 private: 32 uint32 fHash[8]; 33 uint32 fDigest[8]; 34 uint32 fBuffer[64]; 35 size_t fBytesInBuffer; 36 size_t fMessageSize; 37 bool fDigested; 38 }; 39 40 41 } // namespace BPrivate 42 43 using BPrivate::SHA256; 44 45 46 #endif // _SHA_256_H 47