C ++ → Recursive XOR

I used to deal with cryptography some time ago and thought of my own algorithm.

A part of this I will introduce to you. I call it recursive XOR. The reason behind this is that you encode an entire byte with only one bit.
I will show you the simple principle, which is behind it in a brief example:
We take a byte we want to encrypt (01001110) and a bit (1).
We apply XOR to the first bit of the Plain Byte and the bit. Result is in this case 1. This 1 is now the key for the next XOR link from the second bit from the Plain Byte.

This is what we repeat until we are through:

01001110: Plain Byte
11000101: Key Byte
10001011: Crypted byte

Another example:
01101011: Plain byte
00100110: Key Byte
01001101: Crypted byte

This method lives on that of course this is not only encrypted with one bit but with several bits in succession. The key length is arbitrary.
This method was used in a program for communication, therefore the input in String and Character:

Unsigned char GetRekXor (unsigned char ch, string keystr) {
Unsigned char spot, round;
For (unsigned int i = 0; i <keystr.size (); i ++) {
Keych = keystr [i];
For (int j = 128; j> 0; j / = 2) {
Round = keych & j;
Position = 128;
If (round)
Ch = ch ^ 128;
For (int k = 0; k <7; k ++) {
Ch = ch ^ ((& place & ch) >> 1);
Place = place >> 1;
Return ch;

To decrypt the whole, we need the key byte, which we then take with the Crypted Byte Bitwise XOR to get the Plain Byte.
The key byte is obtained by the Crypted by moving this one position to the right (division by two) and the MSB (the bit with the significance 128) equal to the respective key bit. So in example one it would be set in example two however not.

Unsigned char GetReRekXor (byte ch, string keystr) {
Unsigned char keych;
For (int i = keystr.size () - 1; i> = 0; i -) {
Keych = keystr [i];
For (int j = 1; j <129; j * = 2) {
Ch = ch ^ (ch >> 1);
If (keych & j)
Ch = ch ^ 128;
Return ch;

RecXor again in ASM

I will write an article about cryptoanalysis.

Leave a Reply

Your email address will not be published. Required fields are marked *