| 53 | } |
| 54 | |
| 55 | std::string toHex(const std::string& s) { |
| 56 | std::ostringstream oss; |
| 57 | for (unsigned char c : s) |
| 58 | oss << std::hex << std::setw(2) << std::setfill('0') << (int)c; |
| 59 | return oss.str(); |
| 60 | } |
| 61 | |
| 62 | std::string fromHex(const std::string& hex) { |
| 63 | if (hex.size() % 2 != 0) throw std::runtime_error("Invalid hex length"); |