Java Digest digest(byte[] bytes, String algorithm)

Here you can find the source of digest(byte[] bytes, String algorithm)

Description

digest

License

Apache License

Declaration

public static String digest(byte[] bytes, String algorithm) 

Method Source Code


//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);
        }
    }
}

Related

  1. digest(byte[] buffer)
  2. digest(byte[] bytes)
  3. digest(byte[] bytes, String algorithmName)
  4. digest(byte[] bytes, String txt)
  5. digest(byte[] data)
  6. digest(byte[] data, String algorithm)