"Fossies" - the Fresh Open Source Software Archive

Member "unrar/hash.hpp" (4 May 2022, 999 Bytes) of package /linux/misc/unrarsrc-6.1.7.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "hash.hpp" see the Fossies "Dox" file reference documentation.

    1 #ifndef _RAR_DATAHASH_
    2 #define _RAR_DATAHASH_
    3 
    4 enum HASH_TYPE {HASH_NONE,HASH_RAR14,HASH_CRC32,HASH_BLAKE2};
    5 
    6 struct HashValue
    7 {
    8   void Init(HASH_TYPE Type);
    9   bool operator == (const HashValue &cmp);
   10   bool operator != (const HashValue &cmp) {return !(*this==cmp);}
   11 
   12   HASH_TYPE Type;
   13   union
   14   {
   15     uint CRC32;
   16     byte Digest[SHA256_DIGEST_SIZE];
   17   };
   18 };
   19 
   20 
   21 #ifdef RAR_SMP
   22 class ThreadPool;
   23 class DataHash;
   24 #endif
   25 
   26 
   27 class DataHash
   28 {
   29   private:
   30     HASH_TYPE HashType;
   31     uint CurCRC32;
   32     blake2sp_state *blake2ctx;
   33 
   34 #ifdef RAR_SMP
   35     ThreadPool *ThPool;
   36 
   37     uint MaxThreads;
   38     // Upper limit for maximum threads to prevent wasting threads in pool.
   39     static const uint MaxHashThreads=8;
   40 #endif
   41   public:
   42     DataHash();
   43     ~DataHash();
   44     void Init(HASH_TYPE Type,uint MaxThreads);
   45     void Update(const void *Data,size_t DataSize);
   46     void Result(HashValue *Result);
   47     uint GetCRC32();
   48     bool Cmp(HashValue *CmpValue,byte *Key);
   49     HASH_TYPE Type() {return HashType;}
   50 };
   51 
   52 #endif