forked from EvergreenCrypto/docker-finance
container: root: macro: Random: change output to CSV format
The output can now be used with container's CSV tools.
This commit is contained in:
@@ -51,6 +51,7 @@ namespace botan = common::crypto::botan;
|
|||||||
//! \brief CSPRNG macro
|
//! \brief CSPRNG macro
|
||||||
class Random final
|
class Random final
|
||||||
{
|
{
|
||||||
|
//! Text description of number type, random number
|
||||||
using t_rng = std::map<std::string, size_t>;
|
using t_rng = std::map<std::string, size_t>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -110,23 +111,21 @@ class Random final
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Print t_rng Random map of CSPRNG numbers
|
//! \brief Print t_rng of CSPRNG numbers in CSV format
|
||||||
static void generate()
|
static void generate()
|
||||||
{
|
{
|
||||||
auto print = [](const std::string& title, const t_rng& rng) {
|
auto print = [](const std::string& impl, const t_rng& rng) {
|
||||||
std::cout << title << "\n";
|
for (const auto& [type, num] : rng)
|
||||||
|
|
||||||
for (const auto& [label, num] : rng)
|
|
||||||
{
|
{
|
||||||
std::cout << label << ": " << num << "\n";
|
std::cout << impl << "," << type << "," << num << "\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
print("\nRNG (Botan):\n", Random::botan_generate());
|
std::cout << "\nimpl,type,num\n";
|
||||||
print("\nRNG (Crypto++):\n", Random::cryptopp_generate());
|
print("botan::Random", Random::botan_generate());
|
||||||
print("\nRNG (libsodium):\n", Random::libsodium_generate());
|
print("cryptopp::Random", Random::cryptopp_generate());
|
||||||
|
print("libsodium::Random", Random::libsodium_generate());
|
||||||
std::cout << std::endl;
|
std::cout << std::flush;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Wrapper to Random generator
|
//! \brief Wrapper to Random generator
|
||||||
|
|||||||
Reference in New Issue
Block a user