C++ Simple Encryption Algorithm XOR

Posts 1–5 of 5 · Page 1 of 1
C++ Simple Encryption Algorithm XOR
Code:
string XOR(string data, char key[])
{
	string xorstring = data; //initialize new variable for our xordata
	for (int i = 0; i < xorstring.size(); i++) { //for loop for scrambling bits in the string
		xorstring[i] = data[i] ^ key[i % (sizeof(key) / sizeof(char))]; //scrambling the string/descrambling it
	}
	return xorstring;
}
Thanks for the contribution, what would you use this encryption for typically?
Quote Originally Posted by Anton Troskie View Post
Thanks for the contribution, what would you use this encryption for typically?
Quote Originally Posted by R3Dx666 View Post
What's wrong with that question?

- - - Updated - - -

Quote Originally Posted by Anton Troskie View Post
Thanks for the contribution, what would you use this encryption for typically?
Wouldn't use this for files, big data, messages, or any sensitive information. XOR Cipher is pretty easy to crack by analyzing patterns.
But this could be used (needs implementation) to for example encrypt memory of a program at runtime, or secure strings inside a program. This would have good
use for encrypting connections/packets too.
XOR Cipher is pretty easy to crack by analyzing patterns.
You could also release a "how to crack XOR encryption" now!
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us