Here you can find the source of md5(String src)
Parameter | Description |
---|---|
src | a string to digest |
public static String md5(String src)
//package com.java2s; //License from project: Apache License import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { private static MessageDigest md; /**//w w w . j av a 2 s . co m * Calculates the MD5 digest and returns the value as a 32 character hex * string. * * @param src * a string to digest * @return MD5 digest as a hex string */ public static String md5(String src) { try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } md.update(src.getBytes(StandardCharsets.UTF_8)); return String.format("%032x", new BigInteger(1, md.digest())); } }