Here you can find the source of MD5Encoder(String s, String charset)
public final static String MD5Encoder(String s, String charset)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; public class Main { public final static String MD5Encoder(String s, String charset) { try {//from ww w . j a va 2 s .c o m byte[] btInput = s.getBytes(charset); MessageDigest mdInst = MessageDigest.getInstance("MD5"); mdInst.update(btInput); byte[] md = mdInst.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < md.length; i++) { int val = ((int) md[i]) & 0xff; if (val < 16) { sb.append("0"); } sb.append(Integer.toHexString(val)); } return sb.toString(); } catch (Exception e) { return null; } } }