I would like to know an easy way to calculate a 48 bit CRC given a set of bytes.
I have developed: and i believe it to be wrong
public String CheckSum48(Vector<Byte> bytes)
{
long poly = 0x0111552C4310CBL; // polynomial
long rem = 0;
for (byte b : bytes) {
rem = rem ^ (b << 40); //n-8bits
// read 8 bits one at a time
for (int i = 0; i < 8; i++) {
if((rem & 0x8000)==1){
rem = (rem << 1) ^ poly;
}
else
{
rem = rem << 1;
}
rem = rem & 0xffffffffffffL;
}
}
return Long.toBinaryString(rem);
}
I'm not very confident in the method that im using ... Struggling a little with the concept. - any comments on creating a CRC and the steps involved would be appreciated.
Other problems that i feel can be factors..
1. Left bit shift in java is a signed operator.
2. Working with values over 32 bits. Unsure if working in long's is introducing an error.
Any comments on problems with creating CRC's over 32bits in java or possible comments on creating 48 bit CRC's would be appreciated.
Edited by: MichaelFluck on Mar 21, 2010 6:47 PM