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.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { static final char[] HEX_CHARS = "0123456789abcdef".toCharArray(); public static String md5(String s) { MessageDigest md = getMessageDigest("md5"); return bytes2HexString(md.digest(s.getBytes(StandardCharsets.UTF_8))); }/*from w w w . ja v a2 s . c om*/ static MessageDigest getMessageDigest(String name) { try { return MessageDigest.getInstance(name); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } static String bytes2HexString(byte[] b) { StringBuilder sb = new StringBuilder(b.length << 2); for (byte x : b) { int hi = (x & 0xf0) >> 4; int lo = x & 0x0f; sb.append(HEX_CHARS[hi]); sb.append(HEX_CHARS[lo]); } return sb.toString(); } }