2

I need to calculate SHA-2 or SHA-3 of a file. I didn't file any code example showing how to get SHA-2 or SHA-3 of something. It seems even Apach doesn't it.

Is there anyone available?

Incerteza
  • 32,326
  • 47
  • 154
  • 261
  • 1
    Be careful here. SHA 384 is NOT the same as SHA-3. - SHA 384 == SHA2 with a 384 bit key - SHA 3 == Keccak (cfr http://en.wikipedia.org/wiki/SHA-3) A java implementation of Keccak can be found at https://github.com/kocakosm/pitaya/blob/master/src/org/kocakosm/pitaya/security/Keccak.java – Boeboe Jan 29 '15 at 00:43

1 Answers1

2

Yes, apache commons does support SHA 256, SHA 384, and SHA 512. See apache commons DigestUtils.

gefei
  • 18,922
  • 9
  • 50
  • 67
  • DigestUtils uses Java's internal SHA implementation which I believe is SHA-2. See http://en.wikipedia.org/wiki/SHA-2#Comparison_of_SHA_functions – Mohammad Banisaeid Dec 28 '14 at 12:40
  • 2
    Be careful here. SHA 384 is NOT the same as SHA-3. - SHA 384 == SHA2 with a 384 bit key - SHA 3 == Keccak (cfr http://en.wikipedia.org/wiki/SHA-3) A java implementation of Keccak can be found at https://github.com/kocakosm/pitaya/blob/master/src/org/kocakosm/pitaya/security/Keccak.java – Boeboe Jan 29 '15 at 00:47