天天看點

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

校驗和為什麼要%256

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

A checksum is a sequence of numbers and letters used to check data for errors. If you know the checksum of an original file, you can use a checksum utility to confirm your copy is identical.

校驗和是用于檢查資料是否有錯誤的數字和字母序列。 如果您知道原始檔案的校驗和,則可以使用校驗和實用程式來确認您的副本相同。

校驗和說明 (Checksums Explained)

To produce a checksum, you run a program that puts that file through an algorithm. Typical algorithms used for this include MD5, SHA-1, SHA-256, and SHA-512.

要生成校驗和,請運作一個程式,将該檔案放入一個算法中 。 用于此的典型算法包括MD5,SHA-1,SHA-256和SHA-512。

The algorithm uses a cryptographic hash function that takes an input and produces a string (a sequence of numbers and letters) of a fixed length. The input file can be a small 1 MB file or a massive 4 GB file, but either way, you’ll end up with a checksum of the same length. Checksums may also be called “hashes.”

該算法使用一種加密哈希函數,該函數接受輸入并産生固定長度的字元串(數字和字母的序列)。 輸入檔案可以是1 MB的小檔案,也可以是4 GB的大檔案,但是無論哪種方式,您最終都會得到相同長度的校驗和。 校驗和也可以稱為“哈希”。

Small changes in the file produce very different looking checksums. For example, we created two different text files that are almost the same, but one has an exclamation point where the other has a period. After running Windows 10’s built-in checksumming utility on them, we saw very different checksums. A single character difference in the underlying file produces a very different looking checksum.

檔案中的細微變化會産生非常不同的校驗和。 例如,我們建立了兩個幾乎相同的不同文本檔案,但是一個檔案帶有感歎号,另一個檔案帶有句點。 在它們上運作Windows 10的内置校驗和實用程式後,我們看到了截然不同的校驗和。 基礎檔案中的單個字元差異會産生非常不同的校驗和。

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

當校驗和有用時 (When Checksums Are Useful)

You can use checksums to check files and other data for errors that occur during transmission or storage. For example, a file might not have properly downloaded due to network issues, or hard drive problems could have caused corruption in a file on disk.

您可以使用校驗和檢查檔案和其他資料,以檢視在傳輸或存儲期間發生的錯誤。 例如,由于網絡問題,檔案可能沒有正确下載下傳,或者硬碟驅動器問題可能導緻磁盤上的檔案損壞。

If you know the checksum of the original file, you can run a checksum or hashing utility on it. If the resulting checksum matches, you know the file you have is identical.

如果知道原始檔案的校驗和,則可以在其上運作校驗和或哈希實用程式。 如果結果校驗和比對,則說明您擁有的檔案是相同的。

Computers use checksum-style techniques to check data for problems in the background, but you can also do this yourself. For example, Linux distributions often provide checksums so you can verify your Linux ISO properly downloaded before burning it to a disc or putting it on a USB drive. You could also use checksums to verify the integrity of any other type of file, from applications to documents and media. You just need to know the checksum of the original file.

計算機使用校驗和樣式的技術在背景檢查資料是否有問題,但是您也可以自己執行此操作。 例如, Linux發行版通常提供校驗和,是以您可以在将Linux ISO刻錄到CD光牒或将其放入USB驅動器之前,驗證其是否已正确下載下傳。 您還可以使用校驗和來驗證從應用程式到文檔和媒體的任何其他類型檔案的完整性。 您隻需要知道原始檔案的校驗和即可。

MD5,SHA-1和SHA-256和的差別是什麼? (What’s the Difference Between MD5, SHA-1, and SHA-256 Sums?)

Checksums are a useful way to ensure that a file doesn’t have an error. If a random error occurs due to download problems or hard drive issues, the resulting checksum will be different, even if it’s just a tiny error.

校驗和是確定檔案沒有錯誤的有用方法。 如果由于下載下傳問題或硬碟驅動器問題而出現随機錯誤,則即使隻是很小的錯誤,最終的校驗和也會有所不同。

However, these cryptographic hash functions aren’t perfect. Security researchers have found “collisions” with the MD5 and SHA-1 functions. In other words, they’ve found two different files that produce the same MD5 or SHA-1 hash, but are different.

但是,這些密碼哈希函數并不完美。 安全研究人員發現與MD5和SHA-1功能存在“ 沖突 ”。 換句話說,他們發現了兩個不同的檔案,它們産生相同的MD5或SHA-1哈希,但有所不同。

This is unlikely to happen through random chance, but an attacker could use this technique to disguise a malicious file as a legitimate file. That’s why you shouldn’t rely on MD5 or SHA-1 sums to verify that a file is authentic—just to check for corruption.

這不太可能通過随機機會發生,但是攻擊者可以使用此技術将惡意檔案僞裝成合法檔案。 這就是為什麼您不應該依賴MD5或SHA-1總和來驗證檔案的真實性-隻是為了檢查是否損壞。

There haven’t been any reports of an SHA-256 collision yet, which is why applications are now creating SHA-256 sums instead of MD5 sums and SHA-1 sums. SHA-256 is a stronger, more secure algorithm.

還沒有關于SHA-256沖突的報告,這就是為什麼應用程式現在建立SHA-256和而不是MD5和SHA-1和的原因。 SHA-256是一種更強大,更安全的算法。

Different checksum algorithms produce different results. A file will have different MD5, SHA-1, and SHA–256 checksums. If you only know the MD5 sum of an original file, you must calculate your copy’s MD5 sum to check if it’s a match.

不同的校驗和算法産生不同的結果。 檔案将具有不同的MD5,SHA-1和SHA–256校驗和。 如果您隻知道原始檔案的MD5和,則必須計算副本的MD5和以檢查是否比對。

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

如何計算校驗和 (How to Calculate Checksums)

If you know the checksum of an original file and want to check it on your PC, you can do so easily. Windows, macOS, and Linux all have built-in utilities for generating checksums. You don’t need any third-party utilities.

如果您知道原始檔案的校驗和,并希望在您的PC上進行校驗,則可以輕松進行。 Windows,macOS和Linux都具有用于生成校驗和的内置實用程式 。 您不需要任何第三方實用程式。

On Windows, PowerShell’s

Get-FileHash

command calculates the checksum of a file. To use it, first open PowerShell. On Windows 10, right-click the Start button and select “Windows PowerShell.” You can also launch it by searching the Start menu for “PowerShell” and clicking the “Windows PowerShell” shortcut.

在Windows上,PowerShell的

Get-FileHash

指令計算檔案的校驗和。 要使用它,請先打開PowerShell。 在Windows 10上,右鍵單擊“開始”按鈕,然後選擇“ Windows PowerShell”。 您也可以通過在“開始”菜單中搜尋“ PowerShell”并單擊“ Windows PowerShell”快捷方式來啟動它。

Update: Get-FileHash is included with Windows 10. But, on Windows 7, you’ll have to install the PowerShell 4.0 update to get it.

更新: Windows 10附帶有Get-FileHash。但是,在Windows 7上,必須安裝PowerShell 4.0更新才能擷取它。

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

At the prompt, type

Get-FileHash

and then press your space bar.

在提示符下,鍵入

Get-FileHash

,然後按空格鍵。

Type the path of the file you want to calculate the checksum for. Or, to make things easier, drag and drop the file from a File Explorer window onto the PowerShell window to automatically fill in its path.

輸入要為其計算校驗和的檔案的路徑。 或者,為了使事情變得容易,請将檔案從“檔案資料總管”視窗拖放到PowerShell視窗以自動填寫其路徑。

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

Press Enter to run the command, and you’ll see the SHA-256 hash for the file. Depending on the size of the file and the speed of your computer’s storage, the process may take a few seconds.

按Enter鍵運作指令,您将看到檔案的SHA-256哈希。 根據檔案大小和計算機存儲速度的不同,該過程可能需要幾秒鐘。

If you need another type of checksum, add the appropriate

-Algorithm

option to the end of the command, like so:

如果您需要另一種類型的校驗和,請在指令末尾添加适當的

-Algorithm

選項,如下所示:

Compare the calculated checksum to the original one. You shouldn’t have to look too close, as there will be a massive difference in the checksum even if there’s only a tiny difference in the underlying file.

将計算出的校驗和與原始校驗和進行比較。 您不必看起來太近,因為即使基礎檔案隻有很小的差異,校驗和也會有很大的差異。

校驗和為什麼要%256_什麼是校驗和(以及為什麼要關心)?

If the checksum matches, the files are identical. If not, there’s a problem—perhaps the file is corrupted, or you’re just comparing two different files. If you downloaded a copy of the file and its checksum doesn’t match what you expect, try downloading the file again.

如果校驗和比對,則檔案相同。 如果不是,那就有問題-也許檔案已損壞,或者您隻是在比較兩個不同的檔案。 如果您下載下傳了該檔案的副本,并且其校驗和與預期的不符,請嘗試再次下載下傳該檔案。

翻譯自: https://www.howtogeek.com/363735/what-is-a-checksum-and-why-should-you-care/

校驗和為什麼要%256