I can't figure out what I'm doing wrong here. I have the following code:
byte[] digest = new byte[0];
MessageDigest md = null;
try{
md = MessageDigest.getInstance( "SHA-512" );
}
catch( NoSuchAlgorithmException e ) {
return digest;
}
digest = md.digest( myString.getBytes() );
Looking at the hex values of digest byte[] in the NetBeans debugger, it shows something different than the output of:
echo "myString" | openssl dgst -sha512
I'm guessing it's a character encoding issue, but doesn't the JVM and openssl use the default character set for the machine?
Any help is appreciated.
"myString"
, since that's pure ASCII. But you might want to examine the return value ofmyString.getBytes()
just to make sure. – Epicycle