Preparing signature generation

Moving back into our fuzz_file() function, we evaluate the provided file to see whether it has any content, and if so, open the file. We store this file size for later use:

122     fsize = os.stat(file_path).st_size123     if fsize == 0:124         logger.warning("File is 0-bytes. Skipping...")125         return ""126     open_file = open(file_path, 'rb')

We now start with our first factor in the hashing algorithm, the reset point. This value is noted as the first value in a signature, as it's used to determine what hashes can be compared. To calculate this number, we start with 3, as selected in the spamsum algorithm as a minimum reset point. We then double the reset point, as shown on line 130, until it's larger than the filesize / 64 ...

Get Learning Python for Forensics - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.