Here you can find the source of digest(byte[] data, String algorithm)
public static byte[] digest(byte[] data, String algorithm)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static byte[] digest(byte[] data, String algorithm) { if (data == null || data.length <= 0) { return null; }/*from w w w .j a v a 2 s . com*/ try { MessageDigest md = MessageDigest.getInstance(algorithm); md.update(data); return md.digest(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } } }