public static byte [ ] reverse ( byte [ ] data ) { for ( int i = 0 , j = data . length - 1 ; i < data . length / 2 ; i ++ , j -- ) { data [ i ] ^= data [ j ] ; data [ j ] ^= data [ i ] ; data [ i ] ^= data [ j ] ; } return data ; }
reverse a byte array in place WARNING the parameter array is altered and returned .