Here you can find the source of md5(String input)
Parameter | Description |
---|---|
input | a parameter |
@SuppressWarnings("nls") public static String md5(String input)
//package com.java2s; /**//from w w w.ja v a 2 s . c om * Copyright (c) 2012 Todoroo Inc * * See the file "LICENSE" for the full license governing this code. */ import java.math.BigInteger; import java.security.MessageDigest; public class Main { /** * Performs an md5 hash on the input string * @param input * @return */ @SuppressWarnings("nls") public static String md5(String input) { try { byte[] bytesOfMessage = input.getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digest = md.digest(bytesOfMessage); BigInteger bigInt = new BigInteger(1, digest); String hashtext = bigInt.toString(16); while (hashtext.length() < 32) { hashtext = "0" + hashtext; } return hashtext; } catch (Exception e) { return ""; } } }