| 13 | namespace Valdi { |
| 14 | |
| 15 | size_t hexStringToBytes(const std::string_view& hexString, Byte* output, size_t outputLength) { |
| 16 | size_t strIndex = 0; |
| 17 | |
| 18 | for (size_t i = 0; i < outputLength; i++) { |
| 19 | if (strIndex + 2 > hexString.size()) { |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | std::string tok; |
| 24 | tok.append(hexString.data() + strIndex, 2); |
| 25 | uint8_t byte = strtol(tok.data(), nullptr, 16); |
| 26 | |
| 27 | output[i] = byte; |
| 28 | |
| 29 | strIndex += 2; |
| 30 | } |
| 31 | |
| 32 | return strIndex; |
| 33 | } |
| 34 | |
| 35 | std::string bytesToHexString(const Byte* input, size_t inputLength) { |
| 36 | std::stringstream stream; |