HashCalc has, at the top, a field called "Data Format" I switch that to "HexString" then type in test value of 9a
in the data field. I run a SHA-1 hash on it and the answer is:13cba177bcfad90e7b3de70616b2e54ba4bb107f
(NOTE: online hashers will hash "9a" as a string resulting in an answer of e8eef065fb7295044d65b305bab18a9a645d1abf
. Which is wrong for this application)
Now, I need to embed this type of hashing into my Java program. This is what I got so far (wrapped in try/catch):
String ss = "9a";
ByteBuffer bb = ByteBuffer.allocate(8);
byte[] ba = bb.putLong(Long.decode("0x"+ss).longValue()).array();
MessageDigest md = MessageDigest.getInstance("SHA-1");
String results = encodeHex(md.digest(ba));
System.out.println("sha:"+results);
However, my result is E73C417858807239DD5BC30BA978C14D57F80834
What am I doing wrong?
EDIT: Added Hex tag back, it seems obvious that the data has to be in some sort of hex format. As HashCalc has to be set to "HexString" and not "TextString" which returns a different result. And the solution could well include a change to how Im dealing with these hex numbers. --> which turned out to be true