Learning Python for Forensics by Preston Miller & Chapin Bryce

Learning Python for Forensics by Preston Miller & Chapin Bryce

Author:Preston Miller & Chapin Bryce [Miller, Preston]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-05-31T04:00:00+00:00


Implementing rolling hashes – hashing_example.py

To generate rolling hashes, we must first open the file whose content we wish to hash and define the chunk size we want to hash. On line 4, we initialize the hash_list set, which will hold rolling hash values as they are generated. The set data type, whose elements must be unique, is preferred in this situation since we are only concerned with capturing a single instance of a hash. This data type will save memory resources by not storing duplicate hashes and reduce processing time when comparing files. We will need to run this code in a directory containing the bundled rabinkarp.py module:

001 import rabinkarp as rk 002 file_obj = open('sample_file.txt', 'rb') 003 chunk_size = 32 004 hash_list = set()



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.