Here's how the XOR encryption works:
For instance, with this file content:
Bank 123456
And this password : Pwd1234
First, we repeat the password to it fit with the file:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| File | B |
a |
n |
k |
|
1 |
2 |
3 |
4 |
5 |
6 |
| Password | P |
w |
d |
1 |
2 |
3 |
4 |
P |
w |
d |
1 |
After it, we convert it into a byte array:
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| -------: | :--------: | :--------: | :--------: | :--------: | :--------: | :--------: | :--------: | :--------: | :--------: | :--------: | :--------: |
| File | 01000010 | 01100001 | 01101110 | 01101011 | 00100000 | 00110001 | 00110010 | 00110011 | 00110100 | 00110101 | 00110110 | |
| Password |01010000|01110111|01100100|00110001|00110010|00110011|00110100|01010000|01110111|01100100|00110001` |
Now we can XOR. XOR checks if 2 bytes are differents, as it:
| A | B | A ⊕ B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
So, applicated to the entire strings:
01000010 01100001 01101110 01101011 00100000 00110001 00110010 00110011 00110100 00110101 00110110
XOR 01010000 01110111 01100100 00110001 00110010 00110011 00110100 01010000 01110111 01100100 00110001
------------------------------------------------------------------------------------------------------
= 00010010 00010110 00001010 01011010 00010010 00000010 00000110 01100011 01000011 01010001 00000111
[!IMPORTANT]
XOR encryption shouldn't be used for very confidental data, because it
is reversible; that means if the attacker has the encrypted file, and
guess a part of the original, it can find the password, and, so, the
entire original file. In the next release, I'll implement a new
encryption method that will prevent to it.