hi everyone...

i have pasted a piece of code below.. can u people please give me a review of this code... i need to know if there's a better way/logic to implement the following functionality.

Functionality:

1. assume input: 0xFE // 1111 1110;

2. shuffle the bits of the above input according to the pbox

permutation box - pbox={7,1,2,3,4,5,6,0} // elements represent where the input bits are supposed to go.

Eg: bit 0 of input is supposed to be the bit 7 of the output.

3. output the number after shuffling as per pbox

Code:#include<stdio.h> int main() { unsigned int a=0xFE; unsigned int i; int p[]={1,7,5,2,0,4,6,3}; unsigned result=0; unsigned int dmsb=0x80; int x; printf("%X\n",a); for(i=0;i<=7;i++) // for 8bit number { if(1 == ( ( a>> i) %2 ) ) result|=(dmsb >> (7-p[i]) ); } printf("%X\n",result); return 0; }

input: FE (hex)

output: 7F (hex)