I need to calculate checksums of quite large files (gigabytes). This can be accomplished using the following method:
private byte[] calcHash(string file
Hash algorithms are expected to handle this situation and are typically implemented with 3 functions:
hash_init()
- Called to allocate resources and begin the hash.
hash_update()
- Called with new data as it arrives.
hash_final()
- Complete the calculation and free resources.
Look at http://www.openssl.org/docs/crypto/md5.html or http://www.openssl.org/docs/crypto/sha.html for good, standard examples in C; I'm sure there are similar libraries for your platform.