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 Long stringMD5FirstHalfToLong(String input) {
        String md5 = stringMD5(input);
        Long result = 0L;
        if (md5 != null && md5.length() > 16) {
            String firstHalf = md5.substring(0, 16);
            result = Long.valueOf(firstHalf, 16);
        }
        return result;
    }

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

@@ -1125,110 +1125,359 @@
     
-S
 tr
-ing md5 = stringMD5(input);%0A        Long result = 0L;%0A        if (md5 != null && md5
+y %7B%0A            MessageDigest messageDigest = MessageDigest.getInstance(%22MD5%22);%0A            byte%5B%5D inputByteArray = input.getBytes();%0A            messageDigest.update(inputByteArray);%0A            byte%5B%5D resultByteArray = messageDigest.digest();%0A            Long result = 0L;%0A            if (resultByteArray != null && (resultByteArray
 .length
-() %3E
+ ==
  16)
+)
  %7B%0A 
@@ -1491,107 +1491,228 @@
     
+ 
-String firstHalf = md5.substring(0, 16);%0A            result = Long.valueOf(firstHalf, 16);%0A
+   int i = 0;%0A                while (i %3C 8) %7B%0A                    int j = 0xFF & resultByteArray%5Bi%5D;%0A                    long l = result %3C%3C 8 %7C j;%0A                    i++;%0A                    result = l;%0A       
         
 %7D%0A  
@@ -1703,24 +1703,25 @@
             
+ 
 %7D%0A        re
@@ -1722,22 +1722,122 @@
     
-return result;
+    %7D%0A            return result;%0A        %7D catch (NoSuchAlgorithmException e) %7B%0A            return null;%0A        %7D
 %0A   
@@ -1913,13 +1913,15 @@
  = %22
-hello
+android
 %22;%0A 

update java md5 demo