proper cmake

This commit is contained in:
2023-06-04 16:10:06 +02:00
parent 13a8b4c35d
commit fdcb0cf0c4
154 changed files with 1273 additions and 1620 deletions

View File

@@ -0,0 +1,34 @@
//
// Created by Stepan Usatiuk on 26.04.2023.
//
#include "../includes/Buzhash.h"
Buzhash::Buzhash(uint32_t blockSize) : blockSize(blockSize), history() {}
uint32_t Buzhash::get() const {
return cur;
}
uint32_t Buzhash::feed(uint8_t in) {
cur = rotr32(cur, 1);
if (history.size() >= blockSize) {
auto oldest = history.back();
history.pop_back();
cur ^= rotr32(randomNumbers[oldest], blockSize);
}
history.emplace_front(in);
cur ^= randomNumbers[in];
return cur;
}
// Circular shift taken from: https://en.wikipedia.org/wiki/Circular_shift
uint32_t Buzhash::rotr32(uint32_t value, unsigned int count) {
const unsigned int mask = CHAR_BIT * sizeof(value) - 1;
count &= mask;
return (value >> count) | (value << (-count & mask));
}