2025-11-28 00:35:46 +09:00

16 lines
446 B
C++

// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#include "pch.h"
std::vector<uint8_t> hexStringToBytes(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);
uint8_t byte = (uint8_t)strtol(byteString.c_str(), nullptr, 16);
bytes.push_back(byte);
}
return bytes;
}