2022-11-04 22:46:41 +00:00
|
|
|
// Copyright 2022 Google LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
#ifndef PACKAGER_UTILS_HEX_PARSER_H_
|
|
|
|
#define PACKAGER_UTILS_HEX_PARSER_H_
|
|
|
|
|
2023-08-31 23:59:46 +00:00
|
|
|
#include <cstdint>
|
2022-11-04 22:46:41 +00:00
|
|
|
#include <string>
|
2023-08-31 23:59:46 +00:00
|
|
|
#include <vector>
|
2022-11-04 22:46:41 +00:00
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
|
2023-08-31 23:59:46 +00:00
|
|
|
void HexStringToBytes(const std::string& hex, std::vector<uint8_t>* bytes);
|
|
|
|
|
2022-11-04 22:46:41 +00:00
|
|
|
// If you use absl::HexStringToBytes directly, any invalid byte sequence will
|
|
|
|
// be converted into NUL characters silently. This function will validate the
|
|
|
|
// input.
|
|
|
|
bool ValidHexStringToBytes(const std::string& hex, std::string* bytes);
|
|
|
|
|
2023-08-31 23:59:46 +00:00
|
|
|
// same but output to a vector of uint8_t
|
|
|
|
bool ValidHexStringToBytes(const std::string& hex, std::vector<uint8_t>* bytes);
|
|
|
|
|
2022-11-04 22:46:41 +00:00
|
|
|
} // namespace shaka
|
|
|
|
#endif // PACKAGER_UTILS_HEX_PARSER_H_
|