This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
fortuna/accumulator.h

52 lines
993 B
C
Raw Normal View History

#ifndef FORTUNA_ACCUMULATOR_H
#define FORTUNA_ACCUMULATOR_H
#include "generator.h"
#include "pool.h"
2021-12-28 06:13:03 +01:00
#include <algorithm>
#include <exception>
#include <fmt/core.h>
namespace fortuna {
namespace accumulator {
class Accumulator {
2021-12-28 06:13:03 +01:00
private:
fortuna::generator::Generator *Gen;
public:
constexpr static const unsigned int init_pool_num{0};
2021-12-11 02:27:52 +01:00
auto add_source() -> void;
2021-12-28 06:13:03 +01:00
auto set_gen(fortuna::generator::Generator& Gen) -> void {
this->Gen = std::move(&Gen);
}
auto get_random_data(uint n_bytes) -> std::string {
std::string data{""};
try {
2021-12-28 06:13:03 +01:00
data = this->Gen->generate_random_data(n_bytes);
} catch(std::exception& e) {
fmt::print("{}", e.what());
}
return data;
}
2021-12-28 06:13:03 +01:00
auto call_reseed(const std::string& seed) -> void {
try {
2021-12-28 06:13:03 +01:00
this->Gen->reseed(seed);
} catch(std::exception& e) {
fmt::print("{}", e.what());
}
}
2021-12-28 06:13:03 +01:00
Accumulator();
~Accumulator() noexcept;
}; //class Accumulator
} //namespace accumulator
} //namespace fortuna
#endif//FORTUNA_ACCUMULATOR_H