summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/Security/FnvHash.hpp
diff options
context:
space:
mode:
authorboris <wzn@moneybot.cc>2018-12-20 21:38:04 +1300
committerboris <wzn@moneybot.cc>2018-12-20 21:38:04 +1300
commita5acd4c9a3b24c9d5af3a8f504e5af053fa7fa09 (patch)
tree27bc30d3f35e5daaaa15ee6de066119df8d352c7 /csgo-loader/csgo-client/Security/FnvHash.hpp
parent77b52da44b263df4884be2f35f885d8edccbb6fa (diff)
yo is this loss
Diffstat (limited to 'csgo-loader/csgo-client/Security/FnvHash.hpp')
-rw-r--r--csgo-loader/csgo-client/Security/FnvHash.hpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/csgo-loader/csgo-client/Security/FnvHash.hpp b/csgo-loader/csgo-client/Security/FnvHash.hpp
index da7e80d..35c9ad0 100644
--- a/csgo-loader/csgo-client/Security/FnvHash.hpp
+++ b/csgo-loader/csgo-client/Security/FnvHash.hpp
@@ -4,9 +4,11 @@
// Credits: namazso
// Implements FNV-1a hash algorithm
-namespace detail {
+namespace detail
+{
template <typename Type, Type OffsetBasis, Type Prime>
- struct SizeDependantData {
+ struct SizeDependantData
+ {
using type = Type;
constexpr static auto k_offset_basis = OffsetBasis;
@@ -23,7 +25,8 @@ namespace detail {
struct SizeSelector<64> : SizeDependantData<std::uint64_t, 0xcbf29ce484222325ull, 1099511628211ull> {};
template <std::size_t Size>
- class FnvHash {
+ class FnvHash
+ {
private:
using data_t = SizeSelector<Size>;
@@ -36,14 +39,16 @@ namespace detail {
public:
static __forceinline constexpr auto hash_init(
- ) -> hash {
+ ) -> hash
+ {
return k_offset_basis;
}
static __forceinline constexpr auto hash_byte(
hash current,
std::uint8_t byte
- ) -> hash {
+ ) -> hash
+ {
return (current ^ byte) * k_prime;
}
@@ -51,7 +56,8 @@ namespace detail {
static __forceinline constexpr auto hash_constexpr(
const char(&str)[N],
const std::size_t size = N - 1 /* do not hash the null */
- ) -> hash {
+ ) -> hash
+ {
const auto prev_hash = size == 1 ? hash_init() : hash_constexpr(str, size - 1);
const auto cur_hash = hash_byte(prev_hash, str[size - 1]);
return cur_hash;
@@ -60,7 +66,8 @@ namespace detail {
static auto __forceinline hash_runtime_data(
const void* data,
const std::size_t sz
- ) -> hash {
+ ) -> hash
+ {
const auto bytes = static_cast<const uint8_t*>(data);
const auto end = bytes + sz;
auto result = hash_init();
@@ -72,7 +79,8 @@ namespace detail {
static auto __forceinline hash_runtime(
const char* str
- ) -> hash {
+ ) -> hash
+ {
auto result = hash_init();
do
result = hash_byte(result, *str++);