Arne said:
A hash is calculated based on the byte content.
Why does it make the difference whether those bytes are read
from a single file or from multiple files ?
Arne
Thanks Arne.
I think I might not have explained myself. Let me rephrase it I have no
clue how I to do it. :?
I think best way is to show you my problem with quick example code:
------------------------------------------------------------
MD5CryptoServiceProvider oMD5 = new MD5CryptoServiceProvider();
string sRet;
string s1 = "First String Sample";
string s2 = "Second String Sample";
string s3 = s1 + s2;
byte[] bBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(s1);
sRet = BitConverter.ToString(oMD5.ComputeHash(bBytes)).Replace("-", string.Empty);
System.Diagnostics.Debug.WriteLine(sRet);
bBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(s2);
sRet = BitConverter.ToString(oMD5.ComputeHash(bBytes)).Replace("-", string.Empty);
System.Diagnostics.Debug.WriteLine(sRet);
bBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(s3);
sRet = BitConverter.ToString(oMD5.ComputeHash(bBytes)).Replace("-", string.Empty);
System.Diagnostics.Debug.WriteLine(sRet);
-----------------------------------------------------------------
The output hash is as follows:
s1 = 1EC25881AD012D4CA6E73D1986AE93FB
s2 = D8D46AC432C7251F863C2D5B91FE48FC
s3 = 9E158DDEE697EBAEC2A036F459B02448
Now what I want is basically to be able to hash s1 get the
result and then continue hashing s2 and get the final s3 result.
Right now the only way I know of getting s3 hash is by first
concatenating the strings then running it through ComputeHash.
This isn't much of an issue when the input is a small string, however
if I am trying to hash several files then that is a different matter.
**These files can be large, and the only way I know of doing it, is to
basically combining all the files into a single temporary file and then
passing the stream to ComputeHash.
Surely there has to be a better method.
Any advice?
Thanks