diff --git a/packager/live_packager_test.cc b/packager/live_packager_test.cc index af84edc4d90..943d33c48b1 100644 --- a/packager/live_packager_test.cc +++ b/packager/live_packager_test.cc @@ -64,28 +64,10 @@ std::vector ReadTestDataFile(const std::string& name) { return data; } -uint8_t hex_char_to_int(const char& c) { - unsigned result = 0; - if (c >= '0' && c <= '9') { - result = c - '0'; - } else if (c >= 'A' && c <= 'F') { - result = c - 'A' + 10; - } else if (c >= 'a' && c <= 'f') { - result = c - 'a' + 10; - } else { - throw std::out_of_range("input character is out of hex range"); - } - - return result; -} std::vector unhex(const std::string& in) { - std::vector out; - for (std::size_t i = 1; i < in.size(); i += 2) { - out.push_back(16 * hex_char_to_int(in[i - 1]) + hex_char_to_int(in[i])); - } - - return out; + auto converted = absl::HexStringToBytes(in); + return {converted.begin(), converted.end()}; } std::vector unbase64(const std::string& base64_string) {