Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

My Linux, I'm in charge! Talking about the integrity and consistency of MD5 check files

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Table of contents:

(1) introduction of MD5

(II) md5sum order

(3) actual combat exercises

(1) introduction of MD5

(1. 1) MD5, or Message-Digest Algorithm 5 (version 5 of the Information-Digest algorithm), is used to ensure the integrity and consistency of information transmission. Is one of the hash algorithms (also known as abstract algorithm, hash algorithm) widely used in computers, and the mainstream programming languages have been implemented by MD5. Calculating the data to another fixed length value (32 bits in hexadecimal) is the basic principle of the hash algorithm. The predecessor of MD5 is MD2, MD3 and MD4. The function of MD5 is that large-capacity information is "compressed" into a secret format (that is, a string of bytes of arbitrary length is transformed into a certain length of hexadecimal string) before signing a private key with digital signature software. In addition to MD5, the more famous ones are sha-1, RIPEMD, Haval and so on.

(1.2) data inconsistencies may occur before and after transmission during network transmission, transfer between devices, copying large files, etc. This situation is easy to occur in a relatively unstable environment such as the network, so it is imperative to check the integrity of the file.

(II) md5sum order

The md5sum command is used to generate and verify the MD5 value of the file, it verifies the contents of the file bit by bit, and verifies the content of the file, independent of the file name, that is, the content of the file is the same, its MD5 value is the same. The md5 value is a 128-bit binary data, and the conversion to hexadecimal is a 32-bit (128ap4) binary value. Md5 check, there is a small probability that different files may generate the same md5, and there are also SHA series check algorithms that are more secure than md5. When transferring on the network, we verify that the source file gets its md5sum. After the transfer is completed, we verify the target file, and compare that if the source file and the target file md5 are the same, it means that the file transfer is normal, otherwise the file is not transferred correctly during the transfer process.

(2.2) usage: md5sum [option] [file], display or check MD5 (128-bit) checksum, if there is no file option, or if the file is "-", then read from standard input. Checksum will be generated in accordance with the RFC 1321 specification, when checked, the input format should be the same as the program's output template format, the default output mode outputs a line of checksum checksum results, and a character to indicate the file type ("*" represents binary, "" space represents plain text), and displays the name of each file at the same time.

-bmam Meltel binary: read in binary mode

-cmam copyright check: read the check value of MD5 from the file and check it.

-tmam Musi text: read in plain text mode (default)

The following three options are useful for verification:

-- quiet: does not output OK for files that have been successfully verified

-- status: nothing is output, and the exit status number is used to display the success

-wrecom copyright: warn against malformed checksums

-- strict with,--check:exit non-zero for any invalid input

-- help: display this help and exit

-- version: displays version information and exits

We can use-- help to view help information.

# md5sum-help

(3) actual combat exercises

(3.1) get the MD5 value of the string, the MD5 of the string "hello", we use md5sum to display or check the MD5 (128-bit) checksum, if there is no file option, or the file is "-", then read from standard input, cut is used to cut columns or fields from standard input or text files, cut text can be pasted into a text file,-d specifies different field delimiters for field spaces and tab keys -F1 represents the first domain.

# echo-n "hello" | md5sum | cut-d''- F1 Mutual-get the MD5 value of the string

(3.2) get the MD5 value of the file. We use the source package qt-4.8.6 downloaded from download.qt.io. You can download it from the official website using the following command, and then calculate the MD5 value of the file.

# wget http://download.qt.io/archive/qt/4.8/4.8.6/qt-everywhere-opensource-src-4.8.6.tar.gz-download the software from the official website

# md5sum qt-everywhere-opensource-src-4.8.6.tar.gz | cut-d'- F1 Murray-get the MD5 value of the qt-4.8.6 source package

We need to know the MD5 value of the file first. Generally speaking, the download address of the file will provide us with md5 files for verification. Generally speaking, these files are generated using the following command. Then put qt-everywhere-opensource-src-4.8.6.tar.gz and its verification file qt-everywhere-opensource-src-4.8.6.tar.gz.md5 in the same directory (figure 2-5), and then verify it using the following command (figure 2-6).

# md5sum qt-everywhere-opensource-src-4.8.6.tar.gz > qt-everywhere-opensource-src-4.8.6.tar.gz.md5--- generates a md5 file using qt-4.8.6 's source package

# mkdir md5test--- create a md5test file

# mv qt-everywhere-opensource-src-4.8.6.tar.gz qt-everywhere-opensource-src-4.8.6.tar.gz.md5 md5test/--- put the source package and verification files of qt-4.8.6 in a unified directory

# md5sum-c qt-everywhere-opensource-src-4.8.6.tar.gz.md5--- uses md5sum to verify the integrity of downloaded files

Of course, for the files we download, md5 is used to check the integrity of the downloaded files. Naturally, we cannot use the md5 verification files generated by ourselves. Generally speaking, the download website of the files will provide us with md5 files for inspection. The md5 check file of qt-everywhere-opensource-src-4.8.6.tar.gz can be downloaded from http://download.qt.io/archive/qt/4.8/4.8.6/md5sums-4.8.6, and we can view the contents of md5sums-4.8.6.

# wget http://download.qt.io/archive/qt/4.8/4.8.6/md5sums-4.8.6-download the verification file

# cat md5sums-4.8.6--- to view the contents of the verification file

Finally, we put the qt-everywhere-opensource-src-4.8.6.tar.gz software and md5sums-4.8.6 verification files in the / root/ home directory, and then verify the files. At this point, we find that the first file is confirmed to exist, and the other files are validated because there is no download showing that the opening failed.

# md5sum-c md5sums-4.8.6

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report