── XOR ───────────────────────────────────────────────────────
| 44 | |
| 45 | // ── XOR ─────────────────────────────────────────────────────── |
| 46 | std::string xorCipher(const std::string& text, const std::string& key) { |
| 47 | if (key.empty()) throw std::runtime_error("Key cannot be empty"); |
| 48 | std::string result; |
| 49 | for (size_t i = 0; i < text.size(); i++) { |
| 50 | result += (char)(text[i] ^ key[i % key.size()]); |
| 51 | } |
| 52 | return result; |
| 53 | } |
| 54 | |
| 55 | std::string toHex(const std::string& s) { |
| 56 | std::ostringstream oss; |