Here you can find the source of md5(String s)
public static String md5(String s) throws NoSuchAlgorithmException
//package com.java2s; /*//from w w w . j a v a 2 s. c om * (C) 2007-2012 Alibaba Group Holding Limited. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * Authors: * leiwen <chrisredfield1985@126.com> , boyan <killme2008@gmail.com> */ import java.security.NoSuchAlgorithmException; public class Main { public static String md5(String s) throws NoSuchAlgorithmException { String result = ""; java.security.MessageDigest m = java.security.MessageDigest .getInstance("MD5"); m.update(s.getBytes(), 0, s.length()); byte[] bytes = m.digest(); for (int i = 0; i < bytes.length; i++) { String vs = Integer.toHexString(bytes[i] & 0xff); if (vs.length() < 2) { vs = '0' + vs; } result += vs; } return result; } }