Java SHA256 sha256Hash(byte[] data)

Here you can find the source of sha256Hash(byte[] data)

Description

Compute the SHA-256 hash of the given byte array

License

Apache License

Parameter

Parameter Description
data the byte array to hash

Exception

Parameter Description
NoSuchAlgorithmException an exception

Return

the hashed byte array

Declaration

public static byte[] sha256Hash(byte[] data) throws NoSuchAlgorithmException 

Method Source Code

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

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

public class Main {
    /**//ww  w  .j  a  v  a 2  s  .c om
     * Compute the SHA-256 hash of the given byte array
     * @param data the byte array to hash
     * @return the hashed byte array
     * @throws NoSuchAlgorithmException
     */
    public static byte[] sha256Hash(byte[] data) throws NoSuchAlgorithmException {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        return messageDigest.digest(data);
    }
}

Related

  1. sha256Digest(byte[] bytes)
  2. sha256Digest(final InputStream data)
  3. sha256Encode(String message)
  4. sha256encrypt(String phrase)
  5. sha256Hash()
  6. sha256Hash(File file)
  7. sha256Hash(final String tohash)
  8. sha256HashHex(String data)
  9. SHA256Sum(final @Nonnull byte[] bytes)