Search code examples
javasha-3

Calculating SHA 3 Hash in Java


I have been using CryptoJS (i.e. CryptoJS.algo.SHA3.creat()) library to SHA-3 hash on the front end. (see http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha3.js)

I was wondering if there are any Java library equivalence? But so far I haven't found any. There are not so many Java SHA-3 examples either.

sun.security.Provider has SHA-3, but it's not visible under Eclipse. Also, I am not sure whether this sun's SHA-3 is same as the CryptoJS's SHA-3.

Could anyone please provide some examples?


Solution

  • The common Java reference implementation for crypto and crypto support is probably BouncyCastle. It can be a big library to bring in, which is why we often reach into sun.security (rightly or wrongly.)

    Anyway, BouncyCastle seems to offer org.bouncycastle.jcajce.provider.digest.SHA3.DigestSHA3