Rotational XOR Encryption

Posts 17 of 7 · Page 1 of 1
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.
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.
Hope this bumps you guys in the right direction. Example usage to prove it works:
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;
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.
dis here iz da coolest encryption ah've seen in uh while. pimp-tight motha fuckin werk it's amazing all ye damn hood ratz..
@Saltine good work and yes its a lot better than normal xor.. there is one slight problem... your encrypted results can go outside the ascii table boundary, meaning it can and will generate non readable characters, this is fine if you want to first convert all your string to byte array ready for decryption, but wouldn't it be a lot easier to input readable strings, you can do this of cause by using mod function in your algo so you stay within the readable characters.
helped me understand a little more about what i have to do bad thing is i have no idea how to do it LOL so help me please

ok so i have this


Code:
#define STRING_Pickup /*PickupHack*/Dencrypt("Pickup")
#define STRING_WireFrameP /*WireFrame*/Dencrypt("")
#define STRING_Skeleton /*Skeleton*/Dencrypt("")
and i need this


Code:
#define STRING_NxChams /*Nx Chams*/Dencrypt("{¥Mp•Žš*")
#define STRING_ShowxFPS /*Show FPS*/Dencrypt("€•œ¤Ms}€")
#define STRING_CrossHair /*CrossHair*/Dencrypt("pŸœ**uŽ–Ÿ")

basically i need to find a way to turn the Pickup WireFramep and Skeleton into the decrypt code like i have it there for Nx Chams Show FPS and CrossHair


So please help if anyone knows and understands how to make this possible ^.^
Can you give me compiled project?
Quote Originally Posted by GoldWhite View Post
Can you give me compiled project?
There's nothing to compile
That is pretty pimpin.
Posts 17 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?