- 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
推薦閱讀
- 亮劍.NET:.NET深入體驗與實戰精要
- AutoCAD快速入門與工程制圖
- 西門子S7-200 SMART PLC從入門到精通
- 網絡綜合布線技術
- 大數據技術入門(第2版)
- 樂高創意機器人教程(中級 下冊 10~16歲) (青少年iCAN+創新創意實踐指導叢書)
- 視覺檢測技術及智能計算
- 人工智能與人工生命
- Grome Terrain Modeling with Ogre3D,UDK,and Unity3D
- Mastering ServiceNow Scripting
- 邊緣智能:關鍵技術與落地實踐
- Statistics for Data Science
- MATLAB-Simulink系統仿真超級學習手冊
- Mastering Ansible(Second Edition)
- 玩轉PowerPoint