- Machine Learning for Cybersecurity Cookbook
- Emmanuel Tsukerman
- 170字
- 2021-06-24 12:29:02
How it works...
This section will explain the steps that have been provided in the previous section:
- In step 1, we import hashlib, a standard Python library for hash computation. We also specify the file we will be hashing—in this case, the file is python-3.7.2-amd64.exe.
- In step 2, we instantiate an md5 object and an sha256 object and specify the size of the chunks we will be reading.
- In step 3, we utilize the .update(data) method. This method allows us to compute the hash incrementally because it computes the hash of the concatenation. In other words, hash.update(a) followed by hash.update(b) is equivalent to hash.update(a+b).
- In step 4, we print out the hashes in hexadecimal digits.
We can also verify that our computation is consistent with the hash calculations given by other sources, such as VirusTotal and the official Python website. The MD5 hash is displayed on the Python web page (https://www.python.org/downloads/release/python-372/):

The SHA256 hash is computed by uploading the file to VirusTotal (https://www.virustotal.com/gui/home):

推薦閱讀
- GNU-Linux Rapid Embedded Programming
- 精通MATLAB神經網絡
- Managing Mission:Critical Domains and DNS
- 圖解PLC控制系統梯形圖和語句表
- 自動化控制工程設計
- 中國戰略性新興產業研究與發展·智能制造
- 大數據時代
- ESP8266 Robotics Projects
- 液壓機智能故障診斷方法集成技術
- AI的25種可能
- INSTANT VMware vCloud Starter
- Flash CS3動畫制作
- 7天精通Photoshop CS5平面視覺設計
- Microsoft 365 Mobility and Security:Exam Guide MS-101
- SQL語言與數據庫操作技術大全