用于计算模糊哈希的PurePython库(ssdeep)
ppdeep的Python项目详细描述
这是一个纯Python库,用于计算上下文触发的分段散列 通常也被称为“深”或“深”的名字 工具。在一个非常高的层次上,模糊散列是一种确定两个 输入是相似的,而不是相同的。模糊哈希被广泛应用于 数字取证和恶意软件检测。在
这个实现基于AndrewTridgell博士的SpamSum。在
使用
要计算模糊哈希,只需使用hash()函数:
` >>> import ppdeep >>> h1 = ppdeep.hash('The equivalence of mass and energy translates into the well-known E = mc²') >>> h1 '3:RC0qYX4LBFA0dxEq4z2LRK+oCKI9VnXn:RvqpLB60dx8ilK+owX' >>> h2 = ppdeep.hash('The equivalence of mass and energy translates into the well-known E = MC2') >>> h2 '3:RC0qYX4LBFA0dxEq4z2LRK+oCKI99:RvqpLB60dx8ilK+oA' `
要计算相似度,请使用compare()函数,该函数返回 从0到100的整数值(完全匹配):
` >>> ppdeep.compare(h1, h2) 29 `
函数hash_from_file()接受文件名作为参数,并计算 文件内容的哈希:
` >>> ppdeep.hash_from_file('.bash_history') '1536:EXM36dG36x3KW732vOAcg3EP1qKlKozcK0z5G+lEPTssl/7eO7HOBF:tKlKozcWT0' `
安装
` $ pip install ppdeep `
如果要使用最新版本的代码,可以从Git安装:
` $ git clone https://github.com/elceef/ppdeep.git $ cd ppdeep $ pip install . `
- 项目
标签: