Common functions
| 33 | |
| 34 | // Common functions |
| 35 | inline string toHex(const vector<uint8_t> &data) { |
| 36 | string result; |
| 37 | result.reserve(data.size() * 2); |
| 38 | for (uint8_t byte : data) { |
| 39 | char hex[3]; |
| 40 | snprintf(hex, sizeof(hex), "%02x", byte); |
| 41 | result += hex; |
| 42 | } |
| 43 | // Only add '0x' if not already present |
| 44 | if (result.rfind("0x", 0) == 0) { |
| 45 | return result; |
| 46 | } |
| 47 | return "0x" + result; |
| 48 | } |
| 49 | |
| 50 | inline string toHex(const array<uint8_t, 32> &data) { |
| 51 | string result; |
no outgoing calls
no test coverage detected