- 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):

推薦閱讀
- 基于C語(yǔ)言的程序設(shè)計(jì)
- 軟件架構(gòu)設(shè)計(jì)
- Cinema 4D R13 Cookbook
- Maya 2012從入門(mén)到精通
- 21天學(xué)通ASP.NET
- STM32G4入門(mén)與電機(jī)控制實(shí)戰(zhàn):基于X-CUBE-MCSDK的無(wú)刷直流電機(jī)與永磁同步電機(jī)控制實(shí)現(xiàn)
- Supervised Machine Learning with Python
- 大數(shù)據(jù)驅(qū)動(dòng)的設(shè)備健康預(yù)測(cè)及維護(hù)決策優(yōu)化
- 運(yùn)動(dòng)控制系統(tǒng)
- R Data Analysis Projects
- Web璀璨:Silverlight應(yīng)用技術(shù)完全指南
- PowerPoint 2010幻燈片制作高手速成
- 伺服與運(yùn)動(dòng)控制系統(tǒng)設(shè)計(jì)
- Mastering Android Game Development with Unity
- Microsoft Power BI Complete Reference