Here you can find the source of md5(String s)
public static String md5(String s)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static final String[] hexdigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; public static String md5(String s) { try {//w w w .ja v a2 s . c o m MessageDigest md = MessageDigest.getInstance("md5"); md.reset(); md.update(s.getBytes()); byte[] encodedStr = md.digest(); StringBuffer buf = new StringBuffer(); for (byte anEncodedStr : encodedStr) { int n = ((int) anEncodedStr & 0xff); int d1 = n / 16; int d2 = n % 16; buf.append(hexdigits[d1]).append(hexdigits[d2]); } return buf.toString(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } }