Here you can find the source of md5(final String inData)
Parameter | Description |
---|---|
inData | the data string to be hashed. |
Parameter | Description |
---|---|
NoSuchAlgorithmException | If the hashing algorithm can not befound. |
public static String md5(final String inData) throws NoSuchAlgorithmException
//package com.java2s; /*-/* w w w . j av a 2 s . c o m*/ * #%L * Eureka! Clinical User Common * %% * Copyright (C) 2016 Emory University * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /** * Create an MD5 hash from the given string. * * @param inData the data string to be hashed. * @return A hash of the input data string. * @throws NoSuchAlgorithmException If the hashing algorithm can not be * found. */ public static String md5(final String inData) throws NoSuchAlgorithmException { StringBuilder hexBuilder = new StringBuilder(); MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(inData.getBytes()); for (byte b : digest.digest()) { hexBuilder.append(Integer.toHexString(b & 0x00FF)); } return hexBuilder.toString(); } }