Hi everyone,
On PHP, getting hashes is very simple. Consider this code:
echo hash_hmac( "sha512", "abc", "def" );
Which outputs the sha512 hash of "abc" with salt "def", shows
17111e70f32d48a37ccc50a21deb12b40dfe223abf5ac852428000182125dab8a12ee95dd9f526bfb79c1a4fe00a4118e3b525f40eb8291325e3030f2e13ad34
I'm trying to replicate this behavior in Java, and thought I was on the right trail with:
String salt = "def";
MessageDigest md = MessageDigest.getInstance( "SHA-512" );
md.update( salt.getBytes( "UTF-8" ) );
byte [] data = md.digest( String.valueOf( "abc" ).getBytes( "UTF-8" ) );
System.out.println( data );
This however, only outputs trash ([B@190d11) instead of the expected digest. What am I doing wrong?
Thanks for the help.
Alex