本文實例講述了Python獲取文件ssdeep值的方法,分享給大家供大家參考。具體方法如下:
首先,得到ssdeep值,需要先import ssdeep
在ubuntu上安裝pyssdeep時 一直出錯 后來發現apt-cache search "ssdeep"時把幾個全apt-get install 上,但問題依舊。
后來下載到pyssdeep的源文件 ,tar zxvf pyssdeep.tar.zip 然后 apt-get install python-dev 然后 python setup.py install 就安裝上了。
總體來看應該是沒裝python-dev的原因。
具體代碼如下:
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 ssdeep.ssdeep().hash_file(file_path) except: return None
希望本文所述對大家的Python程序設計有所幫助。
新聞熱點
疑難解答