Python获取文件ssdeep值的方法

yipeiwu_com5年前Python基础

本文实例讲述了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程序设计有所帮助。

相关文章

详细讲解Python中的文件I/O操作

详细讲解Python中的文件I/O操作

 本章将覆盖所有在Python中使用的基本I/O功能。有关更多函数,请参考标准Python文档。 打印到屏幕上: 产生输出最简单的方法是使用print语句,可以通过用逗号分隔的...

python回调函数中使用多线程的方法

下面的demo是根据需求写的简单测试脚本 #!/usr/bin/env python # coding: utf-8 # 第一个列表为依赖组件和版本号,后面紧跟负责人名称 # 接着出...

详解pandas使用drop_duplicates去除DataFrame重复项参数

Pandas之drop_duplicates:去除重复项 方法 DataFrame.drop_duplicates(subset=None, keep='first', inpl...

Python+Selenium+PIL+Tesseract自动识别验证码进行一键登录

Python+Selenium+PIL+Tesseract自动识别验证码进行一键登录

本文介绍了Python+Selenium+PIL+Tesseract自动识别验证码进行一键登录,分享给大家,具体如下: Python 2.7 IDE Pycharm 5.0.3...

解决pycharm运行程序出现卡住scanning files to index索引的问题

有时候会出现索引问题,显示scanning files to index 解决方法: in pycharm, go to the "File" on the left top, then...