47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#ifndef FORTUNA_FORTUNA_CPP
|
|
#define FORTUNA_FORTUNA_CPP
|
|
|
|
#include "fortuna.h"
|
|
|
|
#include <cryptopp/cryptlib.h>
|
|
#include <cryptopp/osrng.h>
|
|
#include <cryptopp/hex.h>
|
|
#include <cryptopp/filters.h>
|
|
#include <cryptopp/serpent.h>
|
|
#include <cryptopp/ccm.h>
|
|
#include <fmt/core.h>
|
|
#include <fmt/chrono.h>
|
|
|
|
#include <chrono>
|
|
|
|
|
|
namespace fortuna {
|
|
Fortuna::Fortuna() {
|
|
try {
|
|
initialize_prng();
|
|
} catch(CryptoPP::Exception& e) {
|
|
fmt::print(stderr, "{}\n", e.what());
|
|
}
|
|
}
|
|
Fortuna::~Fortuna() = default;
|
|
|
|
auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
|
const auto start{std::chrono::system_clock::now()};
|
|
fmt::print("random_data starting - {}\n", start);
|
|
incr_reseed_ctr();
|
|
|
|
std::string n{R.Gen.generate_random_data(n_bytes)};
|
|
fmt::print("got you {} proper bytes from generate_random_data -> {}\n",
|
|
n_bytes, n);
|
|
n.erase();
|
|
|
|
const auto end{std::chrono::system_clock::now()};
|
|
std::chrono::duration<double> diff = end-start;
|
|
fmt::print("random_data done - {}\n", end);
|
|
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
|
|
} //random_data
|
|
|
|
} // namespace fortuna
|
|
|
|
#endif//FORTUNA_FORTUNA_CPP
|