I have file that I need to hash, this file can be too large to read into memory at one time, so I need a way using gcrypt to hash the file in more manageable sized chunks how can I do this?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I found how to do this:
The
gcrypthandle is valid and builds upon its input so that whether you write five 1k chunks to the handle or one 5k chunk of data the hash is the same either way. The hash itself is not finalized until you attempt to read it, so you can sit in a loop reading chunks of a large file at a time out and passing them togcryptand thus prevent yourself from ever having too much in memory at one time.