* 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". */
| 168 | * the same as "0b84d1a0806040". |
| 169 | */ |
| 170 | std::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 |