MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / xorCipher

Function xorCipher

lib/cipher.cpp:46–53  ·  view source on GitHub ↗

── XOR ───────────────────────────────────────────────────────

Source from the content-addressed store, hash-verified

44
45// ── XOR ───────────────────────────────────────────────────────
46std::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
55std::string toHex(const std::string& s) {
56 std::ostringstream oss;

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected