Here you can find the source of md5(byte[] source)
Parameter | Description |
---|---|
source | the input buffer |
public static String md5(byte[] source) throws NoSuchAlgorithmException
//package com.java2s; import java.security.NoSuchAlgorithmException; public class Main { /**//from w ww. j ava 2s .com * md5 function * * @param source the input buffer * @return md5 string */ public static String md5(byte[] source) throws NoSuchAlgorithmException { char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); md.update(source); byte tmp[] = md.digest(); char str[] = new char[32]; int k = 0; for (int i = 0; i < 16; i++) { str[k++] = hexDigits[tmp[i] >>> 4 & 0xf]; str[k++] = hexDigits[tmp[i] & 0xf]; } return new String(str); } }