Here you can find the source of sha256Hash(byte[] data)
Parameter | Description |
---|---|
data | the byte array to hash |
Parameter | Description |
---|---|
NoSuchAlgorithmException | an exception |
public static byte[] sha256Hash(byte[] data) throws NoSuchAlgorithmException
//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); } }