I found a flaw or I'm not sure how to deal with hashes . I have two random arrays , one generated by one algorithm and one original. I'm trying to make the algorithm look EXACTLY the same as the original. I visually managed, with the same bytes, the same size in the same positions.
A
isthehashoftheoriginalbyte-array
A¹
isthehashofthegeneratedbyte-array
Ax
arethebytescontainedintheoriginalbyte-array
Ay
arethebytescontainedinthebyte-arraygeneratedbythealgorithm
Notethat,Ax
andAy
arealmostidentical.Butyourhashesaredifferent.What'shappening?
Methodusedtocalculatehashes:
publicstaticstringToHex(byte[]bytes,boolupperCase){using(vark=newHMACSHA256()){bytes=k.ComputeHash(bytes);}StringBuilderresult=newStringBuilder(bytes.Length*2);for(inti=0;i<bytes.Length;i++)result.Append(bytes[i].ToString(upperCase?"X2" : "x2"));
return result.ToString();
}
I'm currently using .NET Standard 2.0.