public static String md5 ( byte [ ] source ) { try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; md . update ( source ) ; byte tmp [ ] = md . digest ( ) ; char str [ ] = new char [ 32 ] ; int k = 0 ; for ( byte b : tmp ) { str [ k ++ ] = hexDigits [ b >>> 4 & 0xf ] ; str [ k ++ ] = hexDigits [ b & 0xf ] ; } return new String ( str ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( e ) ; } }
digest message with MD5