public static String getHexString ( byte [ ] bytes ) { try { byte [ ] hex = new byte [ 2 * bytes . length ] ; int index = 0 ; for ( byte b : bytes ) { int v = b & 0xFF ; hex [ index ++ ] = HEX_CHAR_TABLE [ v >>> 4 ] ; hex [ index ++ ] = HEX_CHAR_TABLE [ v & 0xF ] ; } return new String ( hex , "ASCII" ) ; } catch ( UnsupportedEncodingException e ) { BigInteger bi = new BigInteger ( 1 , bytes ) ; return String . format ( "%0" + ( bytes . length << 1 ) + "x" , bi ) ; } }
Get the hexadecimal string representation of the supplied byte array .