I have a method that takes a mac address from a string and converts it to a byte array. Then I have another method take that byte array and convert it to a long. As Follows
final long address = ((long)addr[5] & 0xff)
+ (((long)addr[4] & 0xff) << 8)
+ (((long)addr[3] & 0xff) << 16)
+ (((long)addr[2] & 0xff) << 24)
+ (((long)addr[1] & 0xff) << 32)
+ (((long)addr[0] & 0xff) << 40);
However I cannot figure out how to convert this long back into a byte array for storage.
I have tried
/* long l = mac in long format address | mac addresses only take 6 bytes */
buffer[currentOffset++] = (byte)l;
buffer[currentOffset++] = (byte)(l >> 8);
buffer[currentOffset++] = (byte)(l >> 16);
buffer[currentOffset++] = (byte)(l >> 24);
buffer[currentOffset++] = (byte)(l >> 32);
buffer[currentOffset++] = (byte)(l >> 40);
It does not convert back correctly though.
You are assigning in reverse order.