Here you can find the source of md5sum(String input)
Parameter | Description |
---|---|
input | a parameter |
public static String md5sum(String input)
//package com.java2s; /****************************************************************************** * Copyright 2015 by OLTPBenchmark Project * * * * 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. * ******************************************************************************/ import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**/*from w w w .j a va 2 s . c o m*/ * Return the MD5 checksum of the given string * @param input * @return */ public static String md5sum(String input) { MessageDigest digest = null; try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException("Unable to compute md5sum for string", ex); } assert (digest != null); digest.update(input.getBytes()); BigInteger hash = new BigInteger(1, digest.digest()); return (hash.toString(16)); } }