accumulator: add generator-interacting methods
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
..and a way to work with the generator
This commit is contained in:
parent
129516a48f
commit
01c402300c
|
@ -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
|
||||
|
|
Reference in New Issue