Link to home
Start Free TrialLog in
Avatar of magdiel linhares
magdiel linhares

asked on

C++ Simple XOR crypt

Hello! I am intercepting packets and want to encrypt them using a simple XOR. The packets are not being encrypted, where am I going wrong?


void process_send(SOCKET s, const char* buf, int *len, int flags) {


			char* q;
			char j = 0;
			int l = sizeof(buf);
			char k;
			int i;
			q = (char *)buf;
			k = q[4];			

			q[4] ^= 0x76;
			for(i = 5; i < l; i++)
			{
			j = q[i];
			q[i] ^= k;
			k = j;
			}
}

Open in new window



Help-me :/
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of magdiel linhares
magdiel linhares

ASKER

Nice! You really made me understand my mistake!
Fine. I'm glad I could help ...

Have a nice weekend,

ZOPPO
>> encrypt them using a simple XOR

Just an observation, but XOR is NOT encryption. It is obfuscation and very easy to reverse engineer. If you are looking to properly encrypt data this is NOT the way to do it!