From 80452ac0abc6494000a9bbad8d7dccfd72ea85f2 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 13 Jun 2026 15:42:15 +0200 Subject: aesxx: upgrade to std::string_view, std::format & --- aesxx/utils/block_dumper.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'aesxx/utils/block_dumper.hpp') diff --git a/aesxx/utils/block_dumper.hpp b/aesxx/utils/block_dumper.hpp index 226ba20..c725670 100644 --- a/aesxx/utils/block_dumper.hpp +++ b/aesxx/utils/block_dumper.hpp @@ -8,13 +8,15 @@ #include #include +#include #include +#include #include template -void dump_block(const char* header, const typename aes::Types::Block& block) { - std::cout << header << ": " << aes::to_string(block) << "\n"; - std::cout << aes::to_matrix_string(block) << "\n"; +void dump_block(std::string_view header, const typename aes::Types::Block& block) { + std::cout << std::format("{}: {}\n", header, aes::to_string(block)); + std::cout << std::format("{}\n", aes::to_matrix_string(block)); } template @@ -24,7 +26,7 @@ void dump_plaintext(const typename aes::Types::Block& block) { template void dump_key(const typename aes::Types::Key& key) { - std::cout << "Key: " << aes::to_string(key) << "\n\n"; + std::cout << std::format("Key: {}\n\n", aes::to_string(key)); } template @@ -40,9 +42,9 @@ void dump_iv(const typename aes::Types::Block& iv) { template void dump_round_keys(const char* header, const typename aes::Types::RoundKeys& round_keys) { - std::cout << header << ":\n"; + std::cout << std::format("{}:\n", header); for (std::size_t i = 0; i < aes::get_number_of_rounds(); ++i) - std::cout << "\t[" << i << "]: " << aes::to_string(round_keys.keys[i]) << "\n"; + std::cout << std::format("\t[{}]: {}\n", i, aes::to_string(round_keys.keys[i])); std::cout << "\n"; } -- cgit v1.3