UsageΒΆ

Import the required module.

>>> import ssdeep

Use the ssdeep.hash() function to compute a fuzzy hash.

>>> hash1 = ssdeep.hash('Also called fuzzy hashes, Ctph can match inputs that have homologies.')
>>> hash1
'3:AXGBicFlgVNhBGcL6wCrFQEv:AXGHsNhxLsr2C'
>>> hash2 = ssdeep.hash('Also called fuzzy hashes, CTPH can match inputs that have homologies.')
>>> hash2
'3:AXGBicFlIHBGcL6wCrFQEv:AXGH6xLsr2C'

The ssdeep.compare() function returns the match score of two hashes. The score is an integer value from 0 (no match) to 100.

>>> ssdeep.compare(hash1, hash2)
22

The ssdeep.hash_from_file() function accepts a filename as argument and calculates the hash of the contents of the file.

>>> ssdeep.hash_from_file('/etc/resolv.conf')
'3:S3yE29cFrrMOoiECAaHJgvn:S3m+COoiUCuvn'

The ssdeep.Hash class provides a hashlib like interface.

>>> h = ssdeep.Hash()
>>> h.update('Also called fuzzy hashes, ')
>>> h.digest()
'3:AXGBicFlF:AXGHR'
>>> h.update('Ctph can match inputs that have homologies.')
>>> h.digest()
'3:AXGBicFlgVNhBGcL6wCrFQEv:AXGHsNhxLsr2C'