From d8d65415d8b8ff1f30fb168c993f3e071083f17e Mon Sep 17 00:00:00 2001 From: "Md. Anisul Haque" Date: Wed, 24 May 2023 02:27:10 +0530 Subject: [PATCH] fix: suggested changes Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com> --- hashing/sha256.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hashing/sha256.cpp b/hashing/sha256.cpp index 5d4f29dcc..03ec158ea 100644 --- a/hashing/sha256.cpp +++ b/hashing/sha256.cpp @@ -182,17 +182,14 @@ std::array compute_hash(const std::string &input) { * @return std::string Final hash value */ std::string hash_to_string(const std::array &hash) { - std::string result; + std::stringstream ss; for (size_t i = 0; i < 8; ++i) { for (size_t j = 0; j < 4; ++j) { uint32_t byte = (hash[i] >> (24 - j * 8)) & 0xFF; - std::stringstream ss; ss << std::hex << std::setfill('0') << std::setw(2) << byte; - result += ss.str(); } } - - return result; + return ss.str(); } /**