diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-13 15:42:15 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-13 15:42:15 +0200 |
| commit | 80452ac0abc6494000a9bbad8d7dccfd72ea85f2 (patch) | |
| tree | 2d46252837083d1d2cfe0aa25d63aa23dfe80714 /aesxx/utils/block_dumper.hpp | |
| parent | workflows/ci: add clang-format job (diff) | |
| download | aes-tools-80452ac0abc6494000a9bbad8d7dccfd72ea85f2.tar.gz aes-tools-80452ac0abc6494000a9bbad8d7dccfd72ea85f2.zip | |
aesxx: upgrade to std::string_view, std::format & <filesystem>
Diffstat (limited to 'aesxx/utils/block_dumper.hpp')
| -rw-r--r-- | aesxx/utils/block_dumper.hpp | 14 |
1 files changed, 8 insertions, 6 deletions
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 <aesxx/all.hpp> #include <cstdlib> +#include <format> #include <iostream> +#include <string_view> #include <type_traits> template <aes::Algorithm algorithm> -void dump_block(const char* header, const typename aes::Types<algorithm>::Block& block) { - std::cout << header << ": " << aes::to_string<algorithm>(block) << "\n"; - std::cout << aes::to_matrix_string<algorithm>(block) << "\n"; +void dump_block(std::string_view header, const typename aes::Types<algorithm>::Block& block) { + std::cout << std::format("{}: {}\n", header, aes::to_string<algorithm>(block)); + std::cout << std::format("{}\n", aes::to_matrix_string<algorithm>(block)); } template <aes::Algorithm algorithm> @@ -24,7 +26,7 @@ void dump_plaintext(const typename aes::Types<algorithm>::Block& block) { template <aes::Algorithm algorithm> void dump_key(const typename aes::Types<algorithm>::Key& key) { - std::cout << "Key: " << aes::to_string<algorithm>(key) << "\n\n"; + std::cout << std::format("Key: {}\n\n", aes::to_string<algorithm>(key)); } template <aes::Algorithm algorithm> @@ -40,9 +42,9 @@ void dump_iv(const typename aes::Types<algorithm>::Block& iv) { template <aes::Algorithm algorithm> void dump_round_keys(const char* header, const typename aes::Types<algorithm>::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<algorithm>(); ++i) - std::cout << "\t[" << i << "]: " << aes::to_string<algorithm>(round_keys.keys[i]) << "\n"; + std::cout << std::format("\t[{}]: {}\n", i, aes::to_string<algorithm>(round_keys.keys[i])); std::cout << "\n"; } |
