Here you can find the source of getHexMd5(byte[] bytes)
Parameter | Description |
---|---|
bytes | array of bytes |
public static final String getHexMd5(byte[] bytes)
//package com.java2s; //License from project: Open Source License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import javax.xml.bind.DatatypeConverter; public class Main { /**//www .j a va 2s. c o m * Get a hex representation of the MD5 checksum of an array of bytes. * * @param bytes * array of bytes * @return lower-case hex digest of the input */ public static final String getHexMd5(byte[] bytes) { MessageDigest digest = null; try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { /** * This really, really cannot happen, because "MD5" = String * constant. */ } digest.update(bytes); String md5 = DatatypeConverter.printHexBinary(digest.digest()).toLowerCase(); return md5; } /** * @see #getHexMd5(byte[]) * @param asText * String to calculate the MD5 {@link MessageDigest} for */ public static final String getHexMd5(String asText) { return getHexMd5(asText.getBytes()); } }