diff --git a/meson.build b/meson.build index 7cd45c5..7e55405 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,8 @@ project('matar', 'cpp', default_options : ['warning_level=3', 'werror=true', 'optimization=3', - 'cpp_std=c++20']) + 'cpp_std=c++20', + 'default_library=static']) compiler = meson.get_compiler('cpp') diff --git a/src/util/crypto.hh b/src/util/crypto.hh index 8bab0d5..f0c4a11 100644 --- a/src/util/crypto.hh +++ b/src/util/crypto.hh @@ -2,8 +2,7 @@ #include #include -#include -#include +#include #include // Why I wrote this myself? I do not know @@ -15,8 +14,8 @@ using std::rotr; template std::string sha256(std::array& data) { - std::stringstream ss; // Assuming 1 byte = 8 bits + std::string string; size_t k = 512 - (N * 8 + 65) % 512; size_t L = N + (65 + k) / 8; size_t i = 0, j = 0; @@ -109,12 +108,12 @@ sha256(std::array& data) { h[j] += h0[j]; } - ss << std::hex << std::setfill('0'); - for (j = 0; j < 8; j++) for (i = 0; i < 4; i++) - ss << std::setw(2) << ((h[j] >> (24 - i * 8)) & 0xFF); + fmt::format_to(std::back_inserter(string), + "{:02x}", + ((h[j] >> (24 - i * 8)) & 0xFF)); - return ss.str(); + return string; } }