I am teaching myself c with some text books i've purchased. Generally this has been pretty easy but one such area i'm not grasping so easily pertains to bit operations. I understand the utilization of the operators in a literal (isolated) sense, but not so much how they apply in the specific context below.
There are 2 such examples below where I havent been able to grasp how/what they are doing in the context of some decryption algorithms.
All im looking for is a bit of an explaination of what the hexadecimal and bit shift/left right would be doing together.
Most of the examples ive been looking through online are in an isolated sense and so far arent quite sinking in to how they are being applied in this scenario.
If there are textbooks specific to bit manipulation / operations that anyone could recommend I'd also be willing to invest in such information. Such is my determination to really nail this down ( I hate moving on without fully grasping something ).
unsigned long lBits = 0;
lBits = ((unsigned long)(key[28] & 0xFFFF)<< 24)|
((unsigned long)(key[29] & 0xFFFF)<< 16)|
((unsigned long)(key[30] & 0xFFFF)<< 8)|
((unsigned long)(key[31] & 0xFFFF));
...
for(i=0; i < max_length ; i++){
unsigned long tBits = lBits | i;
tkey[28] = (unsigned char) (tBits >> 24);
tkey[29] = (unsigned char) (tBits >> 16);
tkey[30] = (unsigned char) (tBits >> 8);
tkey[31] = (unsigned char) (tBits);
key
andtkey
.unsigned char
array, or justchar
?