libxcks  0.1.0.1
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
libgcrypthash.hpp
Go to the documentation of this file.
1 /*
2  * libxcks
3  * Copyright (C) 2022 Julien Couot
4  *
5  * This program is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
24 #ifndef INC_LIBGCRYPTHASH_HPP_7F29545C_1293_4A6B_9980_C4C262F332D1
25 #define INC_LIBGCRYPTHASH_HPP_7F29545C_1293_4A6B_9980_C4C262F332D1
26 
27 //---------------------------------------------------------------------------
28 #include "checksumex.hpp"
29 //---------------------------------------------------------------------------
30 
31 
32 namespace libxcks
33 {
40 class LibgcryptHash : public ChecksumEx
41 {
42  protected:
50  static inline uint32_t rol(uint32_t x, int n)
51  {
52  return ((x << n) | (x >> (32 - n)));
53  }
54 
62  static inline uint32_t ror(uint32_t x, int n)
63  {
64  return ((x >> n) | (x << (32 - n)));
65  }
66 
67  public:
71  void reset() override = 0;
72 };
73 //---------------------------------------------------------------------------
74 } // namespace libxcks
75 //---------------------------------------------------------------------------
76 
77 #endif // INC_LIBGCRYPTHASH_HPP_7F29545C_1293_4A6B_9980_C4C262F332D1
Add some utilities to Checksum class.
Computes a hash from a byte stream.
Definition: checksumex.hpp:72
Computes a hash from a byte stream.
void reset() override=0
Resets the checksum to initial value.
static uint32_t ror(uint32_t x, int n)
Rotate the 32 bit unsigned integer x by n bits right.
static uint32_t rol(uint32_t x, int n)
Rotate the 32 bit unsigned integer x by n bits left.