官术网_书友最值得收藏!

How to do it...

  1.  Begin by importing the ssdeep library and creating three strings:
import ssdeep

str1 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
str2 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore Magna aliqua."
str3 = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore aliqua."
str4 = "Something completely different from the other strings."

  1. Hash the strings:
hash1 = ssdeep.hash(str1)
hash2 = ssdeep.hash(str2)
hash3 = ssdeep.hash(str3)
hash4 = ssdeep.hash(str4)
As a reference,
hash1 is u'3:f4oo8MRwRJFGW1gC6uWv6MQ2MFSl+JuBF8BSnJi:f4kPvtHMCMubyFtQ',
hash2 is u'3:f4oo8MRwRJFGW1gC6uWv6MQ2MFSl+JuBF8BS+EFECJi:f4kPvtHMCMubyFIsJQ',
hash3 is u'3:f4oo8MRwRJFGW1gC6uWv6MQ2MFSl+JuBF8BS6:f4kPvtHMCMubyF0', and
hash4 is u'3:60QKZ+4CDTfDaRFKYLVL:ywKDC2mVL'.
  1. Next, we see what kind of similarity scores the strings have:
ssdeep.compare(hash1, hash1)
ssdeep.compare(hash1, hash2)
ssdeep.compare(hash1, hash3)
ssdeep.compare(hash1, hash4)

The numerical results are as follows:

100
39
37
0

主站蜘蛛池模板: 台东县| 贵定县| 佛坪县| 杭锦旗| 南丰县| 曲松县| 嘉祥县| 扶沟县| 浪卡子县| 文水县| 长宁区| 漳浦县| 恩平市| 南京市| 大洼县| 河北省| 赣榆县| 绍兴市| 兰考县| 河曲县| 南木林县| 汤原县| 房山区| 中山市| 霍林郭勒市| 黔南| 芦山县| 济宁市| 东兴市| 革吉县| 大兴区| 兰州市| 阿瓦提县| 颍上县| 遂宁市| 永胜县| 青州市| 东方市| 修水县| 长泰县| 鹰潭市|