diff --git a/container/src/root/macro/crypto/hash.C b/container/src/root/macro/crypto/hash.C index d1a9998..7dd97a0 100644 --- a/container/src/root/macro/crypto/hash.C +++ b/container/src/root/macro/crypto/hash.C @@ -51,6 +51,7 @@ namespace botan = common::crypto::botan; //! \brief Hash generator macro class Hash final { + //! Text description of Hash impl, encoded digest using t_hash = std::map; public: @@ -221,25 +222,26 @@ class Hash final } public: - //! \brief Print t_hash encoded digest of given message + //! \brief Print t_hash of given message in CSV format + //! \param message Message to encode static void encode(const std::string& message) { - auto print = [](const std::string& title, const t_hash& hash) { - std::cout << title; + std::cout << "\nNOTE: outer quotes (that contain the message) will not be " + "digested. Use escapes to digest literal quotes." + << std::endl; - for (const auto& [label, digest] : hash) + auto print = [](const std::string& message, const t_hash& hash) { + for (const auto& [impl, digest] : hash) { - std::cout << "\n" << label << "\n" << digest << "\n"; + std::cout << impl << ",\"" << message << "\"," << digest << "\n"; } }; - std::cout << "\nMessage:\n\n" << message << "\n"; - - print("\nEncoded (Botan):\n", Hash::botan_encode(message)); - print("\nEncoded (Crypto++):\n", Hash::cryptopp_encode(message)); - print("\nEncoded (libsodium):\n", Hash::libsodium_encode(message)); - - std::cout << std::endl; + std::cout << "\nimpl,message,digest\n"; + print(message, Hash::botan_encode(message)); + print(message, Hash::cryptopp_encode(message)); + print(message, Hash::libsodium_encode(message)); + std::cout << std::flush; } //! \brief Wrapper to encoder