MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / readHex

Function readHex

Tactility/Source/app/chat/ChatSettings.cpp:45–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45static bool readHex(const std::string& input, uint8_t* buffer, size_t length) {
46 if (input.size() != length * 2) {
47 LOGGER.error("readHex() length mismatch");
48 return false;
49 }
50
51 char hex[3] = { 0 };
52 for (size_t i = 0; i < length; i++) {
53 hex[0] = input[i * 2];
54 hex[1] = input[i * 2 + 1];
55 char* endptr;
56 unsigned long val = strtoul(hex, &endptr, 16);
57 if (endptr != hex + 2) {
58 LOGGER.error("readHex() invalid hex character");
59 return false;
60 }
61 buffer[i] = static_cast<uint8_t>(val);
62 }
63 return true;
64}
65
66static bool encryptKey(const uint8_t key[ESP_NOW_KEY_LEN], std::string& hexOutput) {
67 uint8_t iv[16];

Callers 1

decryptKeyFunction · 0.70

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected