Here you can find the source of generateHash(final String input)
Parameter | Description |
---|---|
input | a parameter |
public static String generateHash(final String input)
//package com.java2s; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**/*from w w w . jav a 2 s .c o m*/ * Generates a hashed string in MD5-format for the given string. * * @param input * @return */ public static String generateHash(final String input) { MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(input.getBytes(), 0, input.length()); return new BigInteger(1, messageDigest.digest()).toString(16); } catch (final NoSuchAlgorithmException e) { e.printStackTrace(); throw new RuntimeException("No such hash algorithm!"); } } }