How to XOR a QByteArray?
<p>How would I XOR a QByteArray in C++? I am trying to decrypt a json file that had been XOR encrypted by a python script so I can load it as a QJsonDocument</p>

<p><strong>Update</strong></p>

<pre><code>def encrypt(input):
    key = ['K', 'C', 'Q']
    output = []

    for i in range(len(input)):
        xor_num = ord(input[i]) ^ ord(key[i % len(key)])
        output.append(chr(xor_num))

    return ''.join(output)
</code></pre>

<p>and here is what I have so far in my c++ code for xor the QByteArray:</p>

<pre><code>QByteArray arr = file.readAll();
char key[3] = {'K', 'C', 'Q'};
for (int i = 0; i &lt; arr.size(); i++)
    arr[i] = arr[i] ^ key[i % (sizeof(key) / sizeof(char))];
</code></pre>