Here you can find the source of digestEncrypte(byte[] plainText, String algorithm)
public static String digestEncrypte(byte[] plainText, String algorithm) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String digestEncrypte(byte[] plainText, String algorithm) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest md = MessageDigest.getInstance(algorithm); md.update(plainText);/* www . j ava 2 s.c o m*/ byte[] b = md.digest(); StringBuilder output = new StringBuilder(32); for (int i = 0; i < b.length; i++) { String temp = Integer.toHexString(b[i] & 0xff); if (temp.length() < 2) { output.append("0"); } output.append(temp); } return output.toString(); } }