Here you can find the source of md5(final String data)
Parameter | Description |
---|---|
data | The string to be hashed |
public static String md5(final String data)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**/*from w w w.j a v a 2 s .c o m*/ * Creates the MD5 hash for a given string. * * @param data The string to be hashed * @return The MD5 hash (lowercase) */ public static String md5(final String data) { final StringBuilder hash = new StringBuilder(); try { final MessageDigest digester = MessageDigest.getInstance("MD5"); final byte[] hashedData = digester.digest(data.getBytes()); for (final byte b : hashedData) { hash.append(String.format("%02x", b)); } } catch (final NoSuchAlgorithmException e) { e.printStackTrace(); } return hash.toString(); } }