Generate Whirlpool Hash using Java

Bouncy Castle library

  1. Add bcprov-jdk15on dependency in the build.gradle file:

build.gradle

dependencies {
    implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
}
  1. Generate Whirlpool hash:

src/main/java/app/Main.java

package app;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.encoders.Hex;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Security;

public class Main
{
    public static void main(String[] args) throws NoSuchAlgorithmException
    {
        Security.addProvider(new BouncyCastleProvider());

        String text = "Hello";
        MessageDigest crypt = MessageDigest.getInstance("Whirlpool");
        crypt.update(text.getBytes(StandardCharsets.UTF_8));
        String digest = Hex.toHexString(crypt.digest());

        System.out.println(digest);
    }
}

Leave a Comment

Cancel reply

Your email address will not be published.