import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class CalcMD5 {
    public static String stringMD5(String input) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            byte[] inputByteArray = input.getBytes();
            messageDigest.update(inputByteArray);
            byte[] resultByteArray = messageDigest.digest();
            System.out.println(resultByteArray);
            return byteArrayToHex(resultByteArray);
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
    }

    public static String byteArrayToHex(byte[] byteArray) {
        final String hexDigits = "0123456789abcdef";
        char[] resultCharArray = new char[byteArray.length * 2];
        int index = 0;
        for (byte b : byteArray) {
            resultCharArray[index++] = hexDigits.toCharArray()[(b & 0xf0) >>> 4];
            resultCharArray[index++] = hexDigits.toCharArray()[b & 0xf];
        }

        return new String(resultCharArray);
    }

    public static void main(String[] args) {
        System.out.println(CalcMD5.stringMD5("hello"));
    }
}

@@ -1041,32 +1041,352 @@
 rArray);%0A    %7D%0A%0A
+    public static Long stringMD5FirstHalfToLong(String input) %7B%0A        String md5 = stringMD5(input);%0A        Long result = 0L;%0A        if (md5 != null && md5.length() %3E 16) %7B%0A            String firstHalf = md5.substring(0, 16);%0A            result = Long.valueOf(firstHalf, 16);%0A        %7D%0A        return result;%0A    %7D%0A%0A
     public stati
@@ -1410,24 +1410,56 @@
 g%5B%5D args) %7B%0A
+        String input = %22hello%22;%0A
         Syst
@@ -1491,23 +1491,90 @@
 ringMD5(
-%22hello%22
+input));%0A        System.out.println(CalcMD5.stringMD5FirstHalfToLong(input
 ));%0A    

add java md5 demo