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
|
||||
class Random final
|
||||
{
|
||||
//! Text description of number type, random number
|
||||
using t_rng = std::map<std::string, size_t>;
|
||||
|
||||
public:
|
||||
@@ -110,23 +111,21 @@ class Random final
|
||||
}
|
||||
|
||||
public:
|
||||
//! \brief Print t_rng Random map of CSPRNG numbers
|
||||
//! \brief Print t_rng of CSPRNG numbers in CSV format
|
||||
static void generate()
|
||||
{
|
||||
auto print = [](const std::string& title, const t_rng& rng) {
|
||||
std::cout << title << "\n";
|
||||
|
||||
for (const auto& [label, num] : rng)
|
||||
auto print = [](const std::string& impl, const t_rng& rng) {
|
||||
for (const auto& [type, num] : rng)
|
||||
{
|
||||
std::cout << label << ": " << num << "\n";
|
||||
std::cout << impl << "," << type << "," << num << "\n";
|
||||
}
|
||||
};
|
||||
|
||||
print("\nRNG (Botan):\n", Random::botan_generate());
|
||||
print("\nRNG (Crypto++):\n", Random::cryptopp_generate());
|
||||
print("\nRNG (libsodium):\n", Random::libsodium_generate());
|
||||
|
||||
std::cout << std::endl;
|
||||
std::cout << "\nimpl,type,num\n";
|
||||
print("botan::Random", Random::botan_generate());
|
||||
print("cryptopp::Random", Random::cryptopp_generate());
|
||||
print("libsodium::Random", Random::libsodium_generate());
|
||||
std::cout << std::flush;
|
||||
}
|
||||
|
||||
//! \brief Wrapper to Random generator
|
||||
|
||||
Reference in New Issue
Block a user