SoFunction
Updated on 2024-10-29

Python's way to get the ssdeep value of a file

This article example describes the method of Python to get the file ssdeep value, shared for your reference. Specific methods are as follows:

First, to get the value of ssdeep, you need to first import ssdeep
When installing pyssdeep on ubuntu, I kept getting errors. I later found that apt-cache search "ssdeep" puts a few full apt-get installs on it, but the problem remains.
Then I downloaded the source files for pyssdeep , tar zxvf and apt-get install python-dev then python install and it installed.
Overall it looks like it should be due to not having python-dev installed.

The specific code is as follows:

  def _get_ssdeep(self, file_path): 
    """ 
    Generates the ssdeep fuzzy hash of the file. 
    @return: ssdeep fuzzy hash of the file 
    """ 
    if not IS_SSDEEP: 
      return None 
 
    try: 
      return ().hash_file(file_path) 
    except: 
      return None 

I hope that what I have described in this article will help you in your Python programming.