Java SHA256 digestSHA256(byte[] input)

Here you can find the source of digestSHA256(byte[] input)

Description

Performs a final update on the digest using the specified array of bytes, then completes the digest computation.

License

Apache License

Parameter

Parameter Description
input a parameter

Exception

Parameter Description
NoSuchAlgorithmException an exception

Declaration

public static byte[] digestSHA256(byte[] input) throws NoSuchAlgorithmException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    /**/* w w w .ja v  a  2s .  c o  m*/
     * Performs a final update on the digest using the specified array of bytes, 
     * then completes the digest computation.
     * @param input
     * @return
     * @throws NoSuchAlgorithmException 
     */
    public static byte[] digestSHA256(byte[] input) throws NoSuchAlgorithmException {
        // we do digesting outside the card, because some cards do not support on-card hashing
        MessageDigest digestEngine = MessageDigest.getInstance("SHA-256");

        // we buffer the content to have it after hashing for the PKCS#7 content
        return digestEngine.digest(input);
    }
}

Related

  1. digestSha256(String plain)
  2. digestSha256(String value)
  3. getSHA256(String input)
  4. sha256()