This question says it all. This code
string hash = ""; using (var md5 = System.Security.Cryptography.MD5.Create()) { hash = Convert.ToBase64String(md5.ComputeHash(streamReader.BaseStream)); }
always returns the same hash.
If I transfer all the data from BaseStream to a MemoryStream, it gives a unique hash every time. The same can be said about the launch.
string hash = ""; using (var md5 = System.Security.Cryptography.MD5.Create()) { hash = Convert.ToBase64String(md5.ComputeHash( Encoding.ASCII.GetBytes(streamReader.ReadToEnd()))); }
The second is actually faster, but I heard that this is bad practice.
My question is how to use ComputeHash (stream) correctly. For me, this is always (and I always mean, even if I restart the program, that is, itโs not just hashing the link) returns the same hash, regardless of the data in the stream.
source share