C
chis2k
I need help figuring out how to get the MD5 hash of large files.
I cannot go about the traditional way of reading the entire file into a byte
array, because then the huge file is placed in memory, and bye bye system
resources! I know there might be way using streams, but I am unsure how to
implement it. Can anyone give me an example?
I've tried this but it didn't work, it still loaded the entire blasted thing
into memory!.
public byte[] GetMD5HashFromFile( string file_name) {
FileStream file = new FileStream( file_name, FileMode.Open );
MD5 md5 = new MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
return retVal;
}
I cannot go about the traditional way of reading the entire file into a byte
array, because then the huge file is placed in memory, and bye bye system
resources! I know there might be way using streams, but I am unsure how to
implement it. Can anyone give me an example?
I've tried this but it didn't work, it still loaded the entire blasted thing
into memory!.
public byte[] GetMD5HashFromFile( string file_name) {
FileStream file = new FileStream( file_name, FileMode.Open );
MD5 md5 = new MD5CryptoServiceProvider();
byte[] retVal = md5.ComputeHash(file);
file.Close();
return retVal;
}