0

I found myself in the need to hash something in Java and as I don't understand hashing I'm here.

I already found that there's no simple method for it.

So my question: how is whirlpool hashing done in Java?

EDIT: I was suggested GNU Whirlpool, but I can't get it to work

            Whirlpool wp = new Whirlpool();

            String s = "The quick brown fox jumps over the lazy dog";
            byte[] b = s.getBytes(Charset.forName("UTF-8"));
            wp.update(b, 0, s.length());
            byte[] r = wp.digest();

            String str = new String(r,Charset.forName("UTF-8"));
            System.out.println(str);

And the output is: <?R??XF ????n?g?Tl??H?po??????? m? 5?F ?? y?QhTM?|?I??? Am I missing something? Or did I not understand how it works?

Solve: It seems the digest method outputs raw byte data. I converted it to HEX format using a method from Apache common codec library.

Emil Laine
  • 41,598
  • 9
  • 101
  • 157
Justas S
  • 584
  • 4
  • 12
  • 34

1 Answers1

3

Use GNU Whirlpool. This is a java implementation of Whirlpool from GNU.

RaviH
  • 3,544
  • 2
  • 15
  • 14
  • 3
    Could I get an example of it? – Justas S Jan 09 '14 at 17:57
  • 1
    Is there any possible way of getting a code example of this used in a simple console Java application. I think that it would be good to see it in use. Is there something that has to be imported or is it already built into Java? – Doug Hauf Jul 08 '14 at 14:06