I need to convert this code (in C++) into Java code :
short i;
short j;
short k;
short result;
unsigned short m_table[ 256 ]
for ( i = 0 ; i < 256 ; i++ )
{
k = i << 8;
result = 0;
for ( j = 0 ; j < 8 ; j++ )
{
if ( ( result^ k ) & 0x8000 )
result= ( result<< 1 ) ^ 0x1021;
else
result<<= 1;
k <<= 1;
}
m_table[ i ] = (unsigned short) result;
}
...but I never get the same result...
My Java code is:
int i;
int j;
int k;
int result;
int m_table[ 256 ] = new int[256];
for ( i = 0 ; i < 256 ; i++ ) {
k = (i << 8);
result = 0;
for ( j = 0 ; j < 8 ; j++ ) {
if ( (( result^ k ) & 0x8000) != 0)
result= (( result<< 1 ) ^ 0x1021);
else
result<<= 1;
k <<= 1;
}
m_table[ i ] = (result);
}