These two codes will give you the same output
NodeJS
var data = "seed";
var crypto = require('crypto');
crypto.createHash('sha256').update(data).digest("hex");
Java
import java.security.MessageDigest;
public class SHAHashingExample
{
public static void main(String[] args)throws Exception
{
String password = "seed";
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(password.getBytes());
byte byteData[] = md.digest();
//convert the byte to hex format method 1
StringBuffer sb = new StringBuffer();
for (int i = 0; i < byteData.length; i++) {
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
System.out.println("Hex format : " + sb.toString());
//convert the byte to hex format method 2
StringBuffer hexString = new StringBuffer();
for (int i=0;i<byteData.length;i++) {
String hex=Integer.toHexString(0xff & byteData[i]);
if(hex.length()==1) hexString.append('0');
hexString.append(hex);
}
System.out.println("Hex format : " + hexString.toString());
}
}
For more details:
NodeJS link
Java link
As pointed out by others it is a matter of how you present data. If in the update function you don't specify nothing - like in the solution I gave above - you are telling to interpret the seed as encoded with the default UTF-8 encoding. Now what's the translation of UTF-8 string seed in hex terms? the answer is 73656564, as you can easily check for example from this online tool
Now let's do a verification. Let's write:
NodeJS
var data = "73656564";
crypto.createHash('sha256').update(data, 'hex').digest('hex');
You will get the same result as well. You are telling to the update function that the data you are providing are an hex representation and must be interpreted as such
Hope this can help clarifying the role of hex