public static String md5Hex ( final String input ) { if ( input == null ) { throw new NullPointerException ( "String is null" ) ; } MessageDigest digest = null ; try { digest = MessageDigest . getInstance ( "MD5" ) ; } catch ( NoSuchAlgorithmException e ) { // this should never happen throw new RuntimeException ( e ) ; } byte [ ] hash = digest . digest ( input . getBytes ( ) ) ; return DatatypeConverter . printHexBinary ( hash ) ; }
Generates an MD5 hash hex string for the input string