Large Files And Hashing

From: chis2k (sfd_at_sdf.com)
Date: 07/26/03


Date: Fri, 25 Jul 2003 15:36:08 -0700


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;
}



Relevant Pages

  • Re: Programming in standard c
    ... I consider having the text file size used for reading the file into ... memory to be used insufficiently often to make it worth caching it. ... size may suck significantly more than getting the binary-mode size ... NOT precalculate the size) and reallocing when needed ...
    (comp.lang.c)
  • Re: Noise Level of the PowerMac G5
    ... Or is it just a little bit more memory slots, ... If you are spending most of your time reading, thinking and editing ... I may have 10 to 15 apps open at once and switching between them a lot, ...
    (comp.sys.mac.misc)
  • Re: Large text file - in memory ( > 60mb)
    ... The file is over 64mb in size, reading it line by line to do a search ... while running the app, it would mean reading/searching the>64mb file many ... Then I have to show this record found (wich ... maybe creating a datatable to ease the search but I'm pretty sure memory ...
    (microsoft.public.dotnet.framework)
  • Re: Off Topic: Memory
    ... Given that my memory is something of a concern to me, ... I've only just started reading it but it addresses the causes ... - the rather haphazard way our brains are built, sort of like kludged ... P.S. haven't tried the test yet - keep forgetting ...
    (rec.music.makers.guitar.acoustic)
  • Re: Programming in standard c
    ... may grow larger between the query and the reading. ... That wider programming environment can provide guarantees ... and learned my craft in the days when memory was ...
    (comp.lang.c)