fortuna: add const and casts where appropriate
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5da8023bd3
commit
4f28612f3f
14
fortuna.cpp
14
fortuna.cpp
@ -75,12 +75,13 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
||||
R.Gen.reseed_interval)) {
|
||||
for (int i = 0; i < static_cast<int>(pools_to_use); ++i) {
|
||||
if (this->R.reseed_ctr %
|
||||
static_cast<int>(pow(2, static_cast<double>(i))) ==
|
||||
static_cast<uint64_t>(pow(2, static_cast<double>(i))) ==
|
||||
0) {
|
||||
try {
|
||||
s.append(
|
||||
fortuna::Util::do_sha(this->R._p_pools->at(i).get_s()));
|
||||
this->R._p_pools->at(i).clear_pool();
|
||||
s.append(fortuna::Util::do_sha(
|
||||
this->R._p_pools->at(static_cast<uint64_t>(i))
|
||||
.get_s()));
|
||||
this->R._p_pools->at(static_cast<uint64_t>(i)).clear_pool();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
fmt::print("{}\n", e.what());
|
||||
@ -99,15 +100,14 @@ auto Fortuna::random_data(unsigned int n_bytes) -> void {
|
||||
throw std::runtime_error("illegal state, PRNG not seeded");
|
||||
}
|
||||
else {
|
||||
std::string n{R.Gen.generate_random_data(n_bytes)};
|
||||
const 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.clear();
|
||||
}
|
||||
|
||||
const auto end{std::chrono::system_clock::now()};
|
||||
std::chrono::duration<float> diff = end - start;
|
||||
const std::chrono::duration<float> diff = end - start;
|
||||
fmt::print("random_data done - {}\n", end);
|
||||
fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12);
|
||||
} // random_data
|
||||
|
Reference in New Issue
Block a user