encryption

Started by
2 comments, last by zackriggle 21 years, 4 months ago
I think that I have encryption all figured out and such, but still, look at my (simple) code that encrypts a single character by flipping bits (a char* can be run through this, as well as int's).
    
char encrypt(char a)
{
	unsigned bitfield :8;
	bitfield = a;
	int offset = 0;
	if(bitfield :1 != bitfield :2)
               bitfield |= 64; // 64 is the 7th bit


	return (char) bitfield;
};
    
Another question: is there a simple way to split a short into 2 bytes and a long into 4 bytes for the latter? [edited by - zackriggle on December 2, 2002 5:02:09 PM]
Advertisement
don''t try to sell it
sorry that was a mean comment

[edited by - petewood on December 2, 2002 6:28:31 PM]

  unsigned long dwLong = 123456;unsigned char* pbyBuff = (unsigned char*)&dwLong  

Now pbyBuff[0] ... pbyBuff[3] contain the four bytes of dwLong.

Member of the Unban Mindwipe Society (UMWS)

This topic is closed to new replies.

Advertisement