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

推薦閱讀
- Introduction to DevOps with Kubernetes
- 高性能混合信號ARM:ADuC7xxx原理與應(yīng)用開發(fā)
- R Data Mining
- Hadoop 2.x Administration Cookbook
- 自主研拋機(jī)器人技術(shù)
- Maya極速引擎:材質(zhì)篇
- CentOS 8 Essentials
- 單片機(jī)C語言應(yīng)用100例
- 教育機(jī)器人的風(fēng)口:全球發(fā)展現(xiàn)狀及趨勢
- Visual Studio 2010 (C#) Windows數(shù)據(jù)庫項目開發(fā)
- 傳感器與自動檢測
- Spark大數(shù)據(jù)商業(yè)實戰(zhàn)三部曲:內(nèi)核解密|商業(yè)案例|性能調(diào)優(yōu)
- FANUC工業(yè)機(jī)器人配置與編程技術(shù)
- Cloudera Hadoop大數(shù)據(jù)平臺實戰(zhàn)指南
- 新一代人工智能與語音識別