0

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..

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by NeoKyrgyz
0

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

Edited by mike_2000_17: Fixed formatting

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.