accumulator: add generator-interacting methods
All checks were successful
continuous-integration/drone/push Build is passing

..and a way to work with the generator
This commit is contained in:
surtur 2021-12-13 13:22:50 +01:00
parent 129516a48f
commit 01c402300c
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

View File

@ -1,7 +1,10 @@
#ifndef FORTUNA_ACCUMULATOR_H
#define FORTUNA_ACCUMULATOR_H
#include "generator.h"
#include "pool.h"
#include <exception>
#include <fmt/core.h>
namespace fortuna {
namespace accumulator {
@ -12,6 +15,30 @@ public:
auto add_source() -> void;
auto set_gen(const fortuna::generator::Generator& _Gen) -> void {
this->Gen = _Gen;
};
auto get_random_data(uint n_bytes) -> std::string {
std::string data{""};
try {
data = this->Gen.generate_random_data(n_bytes);
} catch(std::exception& e) {
fmt::print("{}", e.what());
}
return data;
}
auto call_reseed(const std::string& seed) {
try {
this->Gen.reseed(seed);
} catch(std::exception& e) {
fmt::print("{}", e.what());
}
}
private:
fortuna::generator::Generator Gen;
}; //class Accumulator
} //namespace accumulator