Here you can find the source of MD5(String inputString)
Parameter | Description |
---|---|
inputString | a parameter |
String
containing MD5 hash or null if error caught
public static String MD5(String inputString)
//package com.java2s; import java.security.MessageDigest; public class Main { /**//from ww w .j av a 2 s . c o m * Used to get the MD5 hash of a given string. * * @param inputString * @return <code>String</code> containing MD5 hash or null if error caught */ public static String MD5(String inputString) { try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); byte[] array = messageDigest.digest(inputString.getBytes()); StringBuffer stringBuilder = new StringBuffer(); for (int i = 0; i < array.length; ++i) { stringBuilder.append(Integer.toHexString( (array[i] & 0xFF) | 0x100).substring(1, 3)); } return stringBuilder.toString(); } catch (java.security.NoSuchAlgorithmException e) { } return null; } }