- Machine Learning for Cybersecurity Cookbook
- Emmanuel Tsukerman
- 148字
- 2021-06-24 12:29:07
How to do it...
- 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."
- 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'.
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'.
- 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
推薦閱讀
- Microsoft Power BI Quick Start Guide
- STM32G4入門與電機(jī)控制實(shí)戰(zhàn):基于X-CUBE-MCSDK的無(wú)刷直流電機(jī)與永磁同步電機(jī)控制實(shí)現(xiàn)
- 大學(xué)計(jì)算機(jī)應(yīng)用基礎(chǔ)
- 新編計(jì)算機(jī)組裝與維修
- 邊緣智能:關(guān)鍵技術(shù)與落地實(shí)踐
- Unity Multiplayer Games
- Artificial Intelligence By Example
- 基于ARM9的小型機(jī)器人制作
- 筆記本電腦使用與維護(hù)
- Raspberry Pi 3 Projects for Java Programmers
- 數(shù)據(jù)結(jié)構(gòu)與實(shí)訓(xùn)
- Learn T-SQL Querying
- 工業(yè)機(jī)器人編程指令詳解
- 淘寶網(wǎng)店頁(yè)面設(shè)計(jì)、布局、配色、裝修一本通
- Machine Learning for Healthcare Analytics Projects