Hey guys,
for my current project I need to convert a byte array to a hex value, since I had problems with solving it I googled and found this algorithm:
public static BigInteger convertToBigInteger( byte[] toConvert )
{
BigInteger converted = BigInteger.valueOf( 0 );
for( int i = 0; i < toConvert.length; i++ )
{
converted = converted.shiftLeft( 8 );
converted = converted.add( BigInteger.valueOf( toConvert[i] & 0xff ) );
}
return( converted );
}
So I will get a BigInteger which I can simply convert to a Hex-String.
But I don't get why I have to do this operation: toConvert & 0xFF
Does somebody of you know why I have to do it?
Regards,
red.evil
*staff note: Do not double post!