Project description

Still alpha, but code should be easy enough to follow and expand upon.

Example use:

# returns a Match object (list of signatures) that match the file 'f'withopen(f_name,"rb")asf:derp=get_from_file(f)# returns Match object (list of signatures) that match the file at this file pathherp=get_from_path(f_name)# this can be a string or a bytestring, will raise exception if no matching headers found.Matches(header="%PDF")

file_signatures.compare(header, test_hex_string)

A method that compares a two file headers, the first one directly read
from a file, the second is a a string containing space delimited
hexidecimal byte codes. its a string becuase ‘nn’ is used to represent a
wildcard byte.

header

This is the first x bytes of a file, this can be obtained by opening the
file using open(file_name, 'rb') mode.

To obtain only the first few bytes use the following:

withopen(file_name,'rb')asf:header=f.read(32)

test_hex_string

This is the string of space delimited hexidecimal byte codes
representing the file signature.