MOAL.data_structures.hashes package

Submodules

MOAL.data_structures.hashes.hash_list module

class MOAL.data_structures.hashes.hash_list.HashList(filedata, chunk_size=4)[source]

Bases: MOAL.data_structures.hashes.hashtable.NaiveHashTable

Stores a list of computed hashes for each block of data (specified by offset) for a given string block representing a file-like object.

__init__(filedata, chunk_size=4)[source]
__str__()[source]
compute_hashes(filedata, chunk_size)[source]

Compute a list of hashes for each block of data given by filedata. Chunk size will affect performance since each chunk has to be hashed. This is largely dependent on the hashing algorithm used.

hash(data)[source]
class MOAL.data_structures.hashes.hash_list.MockFile[source]
__init__()
__str__()

MOAL.data_structures.hashes.hashtable module

class MOAL.data_structures.hashes.hashtable.NaiveHashTable[source]

Bases: object

__delitem__(key)
__getitem__(key)
__init__()
__iter__()
__setitem__(key, value)
_naive_hash_value(val)

Compute an integer signature relative to the value given. This is very naive and will result in collisions in a short matter of time. Only here for demo purposes, as this data structure is not performant for production use.

fill_to(x)
fnv_offset_basis = 14695981039346656037L
fnv_prime = 1099511628211
hash(key)

Super naive hashing function - collisions are highly probable.

hash_fnv1(data)
hash_fnv1a(data)

MOAL.data_structures.hashes.rolling_hash module

MOAL.data_structures.hashes.rolling_hash.DEBUG = False

http://courses.csail.mit.edu/6.006/spring11/rec/rec06.pdf

MOAL.data_structures.hashes.rolling_hash._fmt(string)[source]
MOAL.data_structures.hashes.rolling_hash.adler_32(string)[source]

See: https://en.wikipedia.org/wiki/Adler-32#The_algorithm

MOAL.data_structures.hashes.rolling_hash.calculate_rolling_hash(substring, string)[source]

Get list of digit representations for reach string

MOAL.data_structures.hashes.rolling_hash.calculate_rolling_hash_average(substring, string)[source]