Rotational XOR Encryption
Well it seems that people here seem to be under the impression that XOR is the only way to go in encryption, so I figured I'd demonstrate a little combination of a few methods I whipped up to enhance security. So basically what this method does is first it XOR's each character against a key. Then, it rotates the bits of each character, fucking up the string a bit more. After that, it adds the index of each character to it to remove the issue that characters which are the same are still the same after encryption. This is still not great, but it is more secure than standard XOR which can be cracked easily.
Hope this bumps you guys in the right direction. Example usage to prove it works:
Outputs:

If you have any questions dont hesitate to ask. Also don't hesitate to tell me where I made mistakes/ have left room for improvement. Don't mind the unnecessary use of construct like the enum, just did that for the lulz. Also, Rotational XOR Encryption is a BS name, just sounded cool :P
The reason I release this in this section is because the users of this section are those in most dire need of what I have to offer. That is all.
Code:
#define rotateRight(a) __asm ror a, 1
#define rotateLeft(a) __asm rol a, 1
enum rotDir{
ROT_LEFT,
ROT_RIGHT
};
char* xor(char* str, int key){
int len = strlen(str);
char* x = new char[len];
for(int i = 0; i < len; ++i)
x[i] = str[i]^key;
x[len] = 0;
return x;
}
char* rotEachChar(char* str_, rotDir ROTDIR){
int len = strlen(str_);
char* x = new char[len];
char cur;
if(ROTDIR==ROT_LEFT){
for(int i = 0; i < len; ++i)
{
cur = str_[i];
rotateLeft(cur)
x[i] = cur;
}
}
else if (ROTDIR == ROT_RIGHT)
{
for(int i = 0; i < len; ++i)
{
cur = str_[i];
rotateRight(cur)
x[i] = cur;
}
}
else
return "******s";
x[len] = 0;
return x;
}
char* addEach(char* str){
int len = strlen(str);
char* x = new char[len];
for(int i = 0; i < len; ++i)
x[i] = str[i] + i;
x[len] = 0;
return x;
}
char* subEach(char* str){
int len = strlen(str);
char* x = new char[len];
for(int i = 0; i < len; ++i)
x[i] = str[i] - i;
x[len] = 0;
return x;
}
char* encrypt(char* text, int key){
return addEach(rotEachChar(xor(text,key),ROT_RIGHT));
}
char* decrypt(char* text, int key){
return xor(rotEachChar(subEach(text),ROT_LEFT),key);
}
Code:
encrypt() and decrypt() are the only methods you should be calling, the others are used only to perform each individual step.
Code:
char* x = encrypt("HURR DURR IM AN PIZZA",13);
char* y = decrypt(x,13);
cout << "HURR DURR IM AN PIZZA"<<endl << x << endl << y;
If you have any questions dont hesitate to ask. Also don't hesitate to tell me where I made mistakes/ have left room for improvement. Don't mind the unnecessary use of construct like the enum, just did that for the lulz. Also, Rotational XOR Encryption is a BS name, just sounded cool :P
The reason I release this in this section is because the users of this section are those in most dire need of what I have to offer. That is all.

