Java SHA-384 Hash Hex String

Just simple java code of how to get/calculate SHA-384 hash hex code of String.

Pure Java

public static String sha384(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
    MessageDigest md5 = MessageDigest.getInstance("SHA-384");
    byte[] digest = md5.digest(input.getBytes("UTF-8"));
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < digest.length; ++i) {
        sb.append(Integer.toHexString((digest[i] & 0xFF) | 0x100).substring(1, 3));
    return sb.toString();


public static String sha384guava(String input) {
    return Hashing.sha384().newHasher()
            .putString(input, Charsets.UTF_8)

Apache Commons Codec

public static String sha384codec(String input) {
    return DigestUtils.sha384Hex(input);