Here you can find the source of digest(byte[] bytes, String algorithm)
public static String digest(byte[] bytes, String algorithm)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; public class Main { public static String digest(byte[] bytes, String algorithm) { try {// w w w . j a v a 2 s .c o m MessageDigest messageDigest = MessageDigest.getInstance(algorithm); byte[] digest = messageDigest.digest(bytes); return Base64.getEncoder().encodeToString(digest); } catch (NoSuchAlgorithmException ex) { throw new RuntimeException( "Can't send multipart upload. Can't create " + algorithm + " digest. " + ex.getMessage(), ex); } } }