| | |
Keep a number as a byte?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 9
Reputation:
Solved Threads: 1
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..
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
[code]#define cyclicShiftRight(val,shiftBy) ...code here...
[code]#define cyclicShiftRight(val,shiftBy) ...code here...
C Syntax (Toggle Plain Text)
#define cyclicShiftLeft(val,shiftBy) ...code here... //... char num = 0x80; //1000-0000 cyclicShiftRight/Left(num,3); //0000-0100
Last edited by twomers; May 9th, 2009 at 5:35 pm.
![]() |
Similar Threads
- converting a text or xml file into binary format (Visual Basic 4 / 5 / 6)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- creating byte stream (C)
- ASCII to number. I need a brilliant mind. (Assembly)
- Operation on Binary number, Need source code for elementar operation (+-*/) (C)
- What errors can occur while reading a file? (C)
- unsigned character pointer to Hex values (C++)
- Real number to binary? (C)
Other Threads in the C Forum
- Previous Thread: A little help with times and structures.
- Next Thread: create output files
| Thread Tools | Search this Thread |
Tag cloud for C
* adobe api append array arrays bash binarysearch centimeter char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest homework i/o ide infiniteloop initialization interest intmain() iso keyboard kilometer lazy license linked linkedlist linux linuxsegmentationfault list match matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scheduling segmentationfault send shape single socketprogramming spoonfeeding stack standard strchr string strings suggestions system test testautomation unix urboc user whythiscodecausesegmentationfault win32api windows.h






