From 912c54bcac59c78e7526fd47c132aa2bc9701bfa Mon Sep 17 00:00:00 2001 From: "Md. Anisul Haque" Date: Wed, 24 May 2023 15:43:30 +0530 Subject: [PATCH] fix: made some required changes --- hashing/sha256.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hashing/sha256.cpp b/hashing/sha256.cpp index 2431d89aa..4ae846644 100644 --- a/hashing/sha256.cpp +++ b/hashing/sha256.cpp @@ -49,7 +49,8 @@ std::size_t compute_padded_size(const std::size_t input_size) { * @param byte_num Position of byte to be returned * @return uint8_t Byte at position byte_num */ -uint8_t extract_byte(const auto in_value, const std::size_t byte_num) { +template +uint8_t extract_byte(const T in_value, const std::size_t byte_num) { if (sizeof(in_value) <= byte_num) { throw std::out_of_range("Byte at index byte_num does not exist"); } @@ -78,7 +79,7 @@ char get_char(const std::string &input, std::size_t pos) { throw std::out_of_range("pos is out of range"); } return static_cast( - extract_byte(input_size * 8, padded_input_size - pos - 1)); + extract_byte(input_size * 8, padded_input_size - pos - 1)); } /** @@ -195,7 +196,7 @@ std::string hash_to_string(const std::array &hash) { std::stringstream ss; for (size_t i = 0; i < 8; ++i) { for (size_t j = 0; j < 4; ++j) { - uint32_t byte = extract_byte(hash[i], 3 - j); + uint32_t byte = extract_byte(hash[i], 3 - j); ss << std::hex << std::setfill('0') << std::setw(2) << byte; } }