Python获取文件ssdeep值的方法

yipeiwu_com6年前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实现监控linux性能及进程消耗性能的方法

本文以实例形式实现了python监控linux性能以及进程消耗性能的方法,具体实现代码如下: # -*- coding: utf-8 -*- """ Created on Tue J...

python使用str & repr转换字符串

可能比较 low 还是记录一下: str 和 repr的使用过程 str 是一个类型 (int, long 类似), 同样她也可以作为一个工厂方法 实例一个 string re...

Python实现的redis分布式锁功能示例

本文实例讲述了Python实现的redis分布式锁功能。分享给大家供大家参考,具体如下: #!/usr/bin/env python # coding=utf-8 import ti...

Python调用C/C++动态链接库的方法详解

本文以实例讲解了Python调用C/C++ DLL动态链接库的方法,具体示例如下: 示例一: 首先,在创建一个DLL工程(本例创建环境为VS 2005),头文件: //hello.h...

Python3实现将文件归档到zip文件及从zip文件中读取数据的方法

本文实例讲述了Python3实现将文件归档到zip文件及从zip文件中读取数据的方法。分享给大家供大家参考。具体实现方法如下: ''''' Created on Dec 24, 2...