Here you can find the source of md5(String input)
Parameter | Description |
---|---|
input | a parameter |
public static String md5(String input)
//package com.java2s; // The contents of this file are subject to the Mozilla Public License import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**/*from w ww . ja v a 2s.c om*/ * This method hashes whatever string is given to it in md5 * DON'T use when cryptographic strength is important. * @param input * @return */ public static String md5(String input) { String result = input; if (input != null) { MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException( "Can't find MD5 algorithm.", e); } md.update(input.getBytes()); BigInteger hash = new BigInteger(1, md.digest()); result = hash.toString(16); while (result.length() < 32) { result = "0" + result; } } return result; } }