Here you can find the source of md5(String string)
public static String md5(String string)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; public class Main { private static final char[] HEX_CHARS = "0123456789ABCDEF".toCharArray(); public static String md5(String string) { try {//from ww w .java 2 s . c o m return bytesToHex(MessageDigest.getInstance("md5").digest(string.getBytes("UTF-8"))); } catch (Exception e) { return string; } } public static String bytesToHex(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = HEX_CHARS[v >>> 4]; hexChars[j * 2 + 1] = HEX_CHARS[v & 0x0F]; } return new String(hexChars); } }