You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

3 years ago
# LLO - Low Level Obfuscation Utils
3 years ago
This repo contains a list of utils that will probably need to be implimented for LLO.
3 years ago
* llo::utils::generate_random_number, generate a random numerical value.
3 years ago
```cpp
template <typename number_t>
concept is_arithmetic_t = std::is_arithmetic_v<number_t>;
template <is_arithmetic_t number_t>
number_t generate_random_number(const number_t minimum, const number_t maximum)
3 years ago
{
3 years ago
using uniform_distribution_t = std::conditional_t<std::is_integral_v<number_t>, std::uniform_int_distribution<number_t>, std::uniform_real_distribution<number_t>>;
std::random_device random_device;
auto mt = std::mt19937{ random_device() };
auto uniform_distribution = uniform_distribution_t{ minimum, maximum };
return uniform_distribution(mt);
3 years ago
}
3 years ago
```
3 years ago
3 years ago
* llo::utils::hash_t templated class that contains unique std::uint64_t hash value for any given data. use std::hash to compute the hash. https://en.cppreference.com/w/cpp/utility/hash. use std::hash<std::varient> to hash type T and a random uint64_t..
3 years ago
3 years ago
```cpp
3 years ago
template <class T>
class T hash_t
3 years ago
{
hash_t hash(const T& data, std::size_t hash_result)
: data {&data}, hash_result{hash_result}
{}
std::size_t hash_result;
const T* data;
public:
static std::shared_ptr<hash_t> make(const T& data)
{
3 years ago
auto hash = std::hash<std::varient<T, std::uint64_t>>{}(data, llo::utils::generate_random_number<std::uint64_t>());
3 years ago
return std::make_shared<hash_t>(data, hash);
}
T& get_data() const;
std::size_t get_hash() const;
};
3 years ago
```