So könnte das Ganze in C++ aussehen:
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
string xorFunction(vector<int> c, vector<int> k);
string hex2str (string str);
vector<int> c = { 0x04, 0x10, 0x12, 0x00, 0x01, 0x08, 0x67, 0x0a, 0x19, 0x65, 0x0f, 0x03, 0x0a, 0x00 };
vector<int> ka = { 0x45, 0x44, 0x46, 0x41, 0x42, 0x43, 0x47, 0x4B, 0x4D, 0x45, 0x4B, 0x42, 0x5D, 0x4E };
vector<int> kb = { 0x45, 0x44, 0x46, 0x41, 0x42, 0x43, 0x47, 0x4B, 0x4D, 0x45, 0x41, 0x4C, 0x45, 0x4E };
int main()
{
string plain1 = xorFunction(c,ka);
string plain2 = xorFunction(c,kb);
cout << plain1 + "\n";
cout << plain2;
}
string xorFunction(vector<int> c, vector<int> k)
{
vector<string> p;
stringstream ss;
for(int i = 0; i < c.size(); i++) {
ss << hex << (c[i]^k[i]);
string res ( ss.str() );
p.push_back(res);
}
return hex2str(p[p.size()-1]);
}
string hex2str (string str)
{
string tmp;
const char *c = str.c_str();
unsigned int x;
while(*c != 0) {
sscanf(c, "%2X", &x);
tmp += x;
c += 2;
}
return tmp;
}