-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3791 - address other review comments
- Loading branch information
Showing
6 changed files
with
47 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "./utils.hpp" | ||
|
||
namespace bb::utils { | ||
|
||
std::vector<uint8_t> hex_to_bytes(const std::string& hex) | ||
{ | ||
std::vector<uint8_t> bytes; | ||
|
||
for (unsigned int i = 0; i < hex.length(); i += 2) { | ||
std::string byteString = hex.substr(i, 2); | ||
bytes.push_back(static_cast<uint8_t>(strtol(byteString.c_str(), nullptr, 16))); | ||
} | ||
|
||
return bytes; | ||
} | ||
|
||
} // namespace bb::utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace bb::utils { | ||
|
||
/** | ||
* @brief Routine to transform hexstring to vector of bytes. | ||
* | ||
* @param Hexadecimal string representation. | ||
* @return Vector of uint8_t values. | ||
*/ | ||
std::vector<uint8_t> hex_to_bytes(const std::string& hex); | ||
|
||
} // namespace bb::utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters