mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
fix: Apply suggestions from code review
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
parent
0883ad73ca
commit
43bc11a903
@ -33,7 +33,7 @@ class Hash {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void update(const std::array<uint32_t, 64> &blocks);
|
void update(const std::array<uint32_t, 64> &blocks);
|
||||||
std::string to_string();
|
std::string to_string() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,7 +226,7 @@ void Hash::update(const std::array<uint32_t, 64> &blocks) {
|
|||||||
* @brief Convert the hash to a hexadecimal string
|
* @brief Convert the hash to a hexadecimal string
|
||||||
* @return std::string Final hash value
|
* @return std::string Final hash value
|
||||||
*/
|
*/
|
||||||
std::string Hash::to_string() {
|
std::string Hash::to_string() const {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
for (size_t i = 0; i < 8; ++i) {
|
for (size_t i = 0; i < 8; ++i) {
|
||||||
ss << std::hex << std::setfill('0') << std::setw(8) << hash[i];
|
ss << std::hex << std::setfill('0') << std::setw(8) << hash[i];
|
||||||
@ -251,7 +251,7 @@ static void test_extract_byte() {
|
|||||||
bool exception = false;
|
bool exception = false;
|
||||||
try {
|
try {
|
||||||
hashing::sha256::extract_byte<uint32_t>(512, 5);
|
hashing::sha256::extract_byte<uint32_t>(512, 5);
|
||||||
} catch (const std::out_of_range) {
|
} catch (const std::out_of_range &) {
|
||||||
exception = true;
|
exception = true;
|
||||||
}
|
}
|
||||||
assert(exception);
|
assert(exception);
|
||||||
@ -265,7 +265,7 @@ static void test_get_char() {
|
|||||||
bool exception = false;
|
bool exception = false;
|
||||||
try {
|
try {
|
||||||
hashing::sha256::get_char("test", 64);
|
hashing::sha256::get_char("test", 64);
|
||||||
} catch (const std::out_of_range) {
|
} catch (const std::out_of_range &) {
|
||||||
exception = true;
|
exception = true;
|
||||||
}
|
}
|
||||||
assert(exception);
|
assert(exception);
|
||||||
|
Loading…
Reference in New Issue
Block a user