/* Copyright (c) MediaArea.net SARL. All Rights Reserved. * * Use of this source code is governed by a BSD-style license that can * be found in the License.html file in the root of the source tree. */ //--------------------------------------------------------------------------- #ifndef HashWrapperH #define HashWrapperH //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- #include "MediaInfo/Setup.h" #if MEDIAINFO_MD5 || MEDIAINFO_SHA1 || MEDIAINFO_SHA2 #define MEDIAINFO_HASH 1 #else //MEDIAINFO_MD5 || MEDIAINFO_SHA1 || MEDIAINFO_SHA2 #define MEDIAINFO_HASH 0 #endif //MEDIAINFO_MD5 || MEDIAINFO_SHA1 || MEDIAINFO_SHA2 //--------------------------------------------------------------------------- #if MEDIAINFO_HASH //--------------------------------------------------------------------------- #include #include #include "ZenLib/Conf.h" using namespace ZenLib; using std::bitset; using std::string; //--------------------------------------------------------------------------- namespace MediaInfoLib { //*************************************************************************** // Constructor/Destructor //*************************************************************************** //--------------------------------------------------------------------------- class HashWrapper { public: enum HashFunction { #if MEDIAINFO_MD5 MD5, #endif #if MEDIAINFO_SHA1 SHA1, #endif #if MEDIAINFO_SHA2 SHA224, SHA256, SHA384, SHA512, #endif HashFunction_Max, }; typedef bitset HashFunctions; HashWrapper (const HashFunctions &Functions) {Init(Functions);} HashWrapper (const HashFunctions &Functions, const int8u* Buffer, const size_t Buffer_Size) {Init(Functions); Update(Buffer, Buffer_Size);} ~HashWrapper (); void Update (const int8u* Buffer, const size_t Buffer_Size); string Generate (const HashFunction Function); static string Generate (const HashFunction Function, const int8u* Buffer, const size_t Buffer_Size) {return HashWrapper(1<