public static String asHex ( byte [ ] hash ) { StringBuilder buf = new StringBuilder ( hash . length * 2 ) ; int i ; for ( i = 0 ; i < hash . length ; i ++ ) { if ( ( ( int ) hash [ i ] & 0xff ) < 0x10 ) buf . append ( "0" ) ; buf . append ( Long . toString ( ( int ) hash [ i ] & 0xff , 16 ) ) ; } return buf . toString ( ) ; }
Turns array of bytes into string representing each byte as unsigned hex number .