#pragma once
#include <whiteout/common_types.h>
#include <array>
#include <cstring>
#include <span>
namespace whiteout::storages::casc {
static constexpr size_t kEKeyTruncSize = 9;
static constexpr std::array<u8, 16> kZeroKey{};
inline std::span<const u8> eKeyTrunc(const std::array<u8, 16>& key) {
return std::span<const u8>(key.data(), kEKeyTruncSize);
}
inline std::span<const u8> eKeyTrunc(std::span<const u8, 16> key) {
return std::span<const u8>(key.data(), kEKeyTruncSize);
}
inline u64 keyHash64(const u8* key) {
u64 h = 0;
std::memcpy(&h, key, 8);
h ^= static_cast<u64>(key[8]) << 56;
return h;
}
inline u64 keyHash64(const std::array<u8, 16>& key) {
return keyHash64(key.data());
}
inline bool isZeroKey(const std::array<u8, 16>& key) {
return key == kZeroKey;
}
}