Java Utililty Methods SHA512

List of utility methods to do SHA512

Description

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

Method

Stringsha512(String input)
sha
if (input == null) {
    throw new NullPointerException("The input parameter must not be null.");
return encrypt(input, "SHA-512");
StringSHA512(String original)
SHA
String sha512 = "";
try {
    final MessageDigest md = MessageDigest.getInstance("SHA-512");
    md.update(original.getBytes());
    final byte[] digest = md.digest();
    final StringBuilder sb = new StringBuilder();
    for (byte b : digest) {
        sb.append(String.format("%02x", b & 0xff));
...
byte[]sha512(String string)
Hashes the given string using the SHA-512 algorithm.
return hash("SHA-512", string);
Stringsha512(String string)
sha
return calcHash(string, "SHA-512");
byte[]sha512AsBytes(byte[] input)
Generate SHA-512 as bytes.
MessageDigest md = null;
try {
    md = MessageDigest.getInstance("SHA-512");
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
md.update(input);
return md.digest();
...
Stringsha512hash_base64(final String toHash)
shahasbase
final MessageDigest md;
try {
    md = MessageDigest.getInstance("SHA-512");
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("Shouldn't happen");
final byte[] digest = md.digest(toHash.getBytes());
return new String(Base64.getEncoder().encode(digest));
...
byte[]sha512String(String base)
sha String
try {
    MessageDigest digest = MessageDigest.getInstance("SHA-512");
    byte[] enc = base.getBytes("UTF-8");
    byte[] hash = digest.digest(enc);
    return hash;
} catch (Exception ex) {
    throw new RuntimeException(ex);