private static String digestToString ( byte [ ] b ) { StringBuilder result = new StringBuilder ( 128 ) ; for ( byte aB : b ) { result . append ( Integer . toString ( ( aB & 0xff ) + 0x100 , 16 ) . substring ( 1 ) ) ; } return result . toString ( ) ; }
This method convert byte array to string regardless the charset