Java Utililty Methods SHA256

List of utility methods to do SHA256

Description

The list of methods to do SHA256 are organized into topic(s).

Method

byte[]sha256Digest(final InputStream data)
sha Digest
MessageDigest digest = getSHA256MessageDigest();
updateMessageDigest(digest, data);
return digest.digest();
Stringsha256Encode(String message)
sha Encode
return encode("SHA-256", message);
Stringsha256encrypt(String phrase)
shaencrypt
return generateHash(phrase, "SHA-256");
MessageDigestsha256Hash()
sha Hash
return MessageDigest.getInstance("SHA-256");
byte[]sha256Hash(byte[] data)
Compute the SHA-256 hash of the given byte array
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
return messageDigest.digest(data);
byte[]sha256Hash(File file)
Calculate the SHA-256 hash for a given file efficiently.
FileInputStream in = new FileInputStream(file);
return sha256Hash(in);
Stringsha256Hash(final String tohash)
sha Hash
byte[] b = null;
try {
    b = tohash.getBytes("UTF-8");
    MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
    b = sha256.digest(b);
} catch (UnsupportedEncodingException e) {
    throw new Error(e);
} catch (NoSuchAlgorithmException e) {
...
Stringsha256HashHex(String data)
sha Hash Hex
return sha256HashHex(data.getBytes());
byte[]SHA256Sum(final @Nonnull byte[] bytes)
SHA Sum
return sha256.digest(bytes);