MCPcopy Create free account
hub / github.com/avast/retdec / hexStringToBytes

Function hexStringToBytes

src/utils/conversion.cpp:170–183  ·  view source on GitHub ↗

* Convert hexadecimal string @c hexIn string into bytes. * There might be whitespaces in the string, e.g. "0b 84 d1 a0 80 60 40" is * the same as "0b84d1a0806040". */

Source from the content-addressed store, hash-verified

168 * the same as "0b84d1a0806040".
169 */
170std::vector<uint8_t> hexStringToBytes(const std::string& hexIn)
171{
172 std::vector<uint8_t> bytes;
173
174 auto hex = removeWhitespace(hexIn);
175 for (unsigned int i = 0; i < hex.length(); i += 2)
176 {
177 std::string byteString = hex.substr(i, 2);
178 char byte = strtol(byteString.c_str(), nullptr, 16);
179 bytes.push_back(byte);
180 }
181
182 return bytes;
183}
184
185} // namespace utils
186} // namespace retdec

Callers 4

ProgramOptionsMethod · 0.85
TEST_FFunction · 0.85
emulate_binMethod · 0.85

Calls 2

removeWhitespaceFunction · 0.85
lengthMethod · 0.80

Tested by 2

TEST_FFunction · 0.68
emulate_binMethod · 0.68