Here you can find the source of md5(String input)
Parameter | Description |
---|---|
input | the input string |
public static String md5(String input)
//package com.java2s; /*/*from w ww.j ava 2 s.c om*/ * This software is distributed under the terms of the FSF * Gnu Lesser General Public License (see lgpl.txt). * * This program is distributed WITHOUT ANY WARRANTY. See the * GNU General Public License for more details. */ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** * Returns a MD5 digest string of the input string. * * @param input the input string * @return the MD5 digest string */ public static String md5(String input) { try { MessageDigest md = MessageDigest.getInstance("MD5"); BigInteger number = new BigInteger(1, md.digest(input .getBytes())); String hashtext = number.toString(16); while (hashtext.length() < 32) { hashtext = "0" + hashtext; } return hashtext; } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } } }