I am using C# in Windows Mobile 5. The program downloads large files from the internet along with their hash values. Then it computes a hash value of the downloaded data and compares it to the expected hash value. The idea is to verify that the entire file was downloaded uncorrupted.
The problem is that the file is large enough to where if I put the entire contents of the file into memory in a byte array, then the device will run out of memory. However I want to do this so that I can compute the hash of the bytes. Is it possible to compute the hash without having all the bytes in memory at once? Preferably I would like to compute SHA1 hashes using the SHA1Managed class, but I am willing to change that if necessary. I did notice that there is an overload of the SHA1Managed.ComputeHash() method that accepts a Stream, but I don't know if it uses any less memory than just pulling all the bytes into memory and the memory profilers I know of for .NET CF are completely useless.