Hello.
I'm developing a encryption program. I'm testing with encryption right now.
I use bitwise operators and also bitwise shifts. [OR [|], XOR[^], AND[&], NOT[~], right[>>],left[<<]]

To add even more security, I went ahead and added bitwise shifts.
Whenever I shift the numbers, they go over 256 [max int in a byte].
Is there any way I can declare the integer so that it doesn't go above 256, and if it does it just overlaps?

I'm sorry I can't explain it well, I know C very little..

No. You'll have to write a cyclic shift macros or function. ie, something like

#define cyclicShiftRight(val,shiftBy) ...code here...
#define cyclicShiftLeft(val,shiftBy) ...code here...
//...
char num = 0x80; //1000-0000
cyclicShiftRight/Left(num,3); //0000-0100

That's going to be a pain in the rear end -.-..
Thanks.

You can store it in a char (8 bit) variable.
Even if "char" gives impression of "character" variable actually it's just a integer of 8 bits.

This should solve you problem if I got it correctly. Otherwise please clarify your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.