Possible to calculate MD5 (or other) hash with buffered reads?

后端 未结 5 1665
长情又很酷
长情又很酷 2020-11-27 03:37

I need to calculate checksums of quite large files (gigabytes). This can be accomplished using the following method:

    private byte[] calcHash(string file         


        
5条回答
  •  自闭症患者
    2020-11-27 04:08

    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.

提交回复
热议问题