Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zackriggle

encryption

This topic is 5735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement

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

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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!