From 4f28612f3fc3c531609f8b4749965fecef6c9823 Mon Sep 17 00:00:00 2001 From: surtur Date: Thu, 20 Jan 2022 05:58:36 +0100 Subject: [PATCH] fortuna: add const and casts where appropriate --- fortuna.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fortuna.cpp b/fortuna.cpp index 3ae5e1c..f6324bd 100644 --- a/fortuna.cpp +++ b/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(pools_to_use); ++i) { if (this->R.reseed_ctr % - static_cast(pow(2, static_cast(i))) == + static_cast(pow(2, static_cast(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(i)) + .get_s())); + this->R._p_pools->at(static_cast(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 diff = end - start; + const std::chrono::duration diff = end - start; fmt::print("random_data done - {}\n", end); fmt::print("getting random data took {:.{}f}s\n", diff.count(), 12); } // random_data