What is the best way to calculate a checksum for a file that is on my machine?

北战南征 提交于 2019-12-20 07:58:27

问题


I'm on a Windows machine and I want to run a checksum on the MySQL distribution I just got. It looks like there are products to download, an unsupported Microsoft tool, and probably other options. I'm wondering if there is a consensus for the best tool to use. This may be a really easy question, I've just never run a checksum routine before.


回答1:


Any MD5 will produce a good checksum to verify the file. Any of the files listed at the bottom of this page will work fine. http://en.wikipedia.org/wiki/Md5sum




回答2:


The CertUtil is a pre-installed Windows utility, that can be used to generate hash checksums:

CertUtil -hashfile pathToFileToCheck [HashAlgorithm]

HashAlgorithm choices: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

So for example, the following generates an MD5 checksum for the file C:\TEMP\MyDataFile.img:

CertUtil -hashfile C:\TEMP\MyDataFile.img MD5

To get output similar to *Nix systems you can add some PS magic:

$(CertUtil -hashfile C:\TEMP\MyDataFile.img MD5)[1] -replace " ",""



回答3:


I personally use Cygwin, which puts the entire smörgåsbord of Linux utilities at my fingertip --- there's md5sum and all the cryptographic digests supported by OpenSSL. Alternatively, you can also use a Windows distribution of OpenSSL (the "light" version is only a 1 MB installer).




回答4:


On Windows : you can use FCIV utility : http://support.microsoft.com/kb/841290

On Unix/Linux : you can use md5sum : http://linux.about.com/library/cmd/blcmdl1_md5sum.htm




回答5:


Checksum tabs: http://code.kliu.org/hashcheck/

This has worked great for me on windows for a while now. It allows easy copying and pasting of checksums. It has box to type/paste check sums from webpages and show matches or non matches quite well.




回答6:


On MySQL.com, MD5s are listed alongside each file that you can download. For instance, MySQL "Windows Essentials" 5.1 is 528c89c37b3a6f0bd34480000a56c372.

You can download md5 (md5.exe), a command line tool that will calculate the MD5 of any file that you have locally. MD5 is just like any other cryptographic hash function, which means that a given array of bytes will always produce the same hash. That means if your downloaded MySQL zip file (or whatever) has the same MD5 as they post on their site, you have the exact same file.




回答7:


When I worked with Windows, I found handy HashTab 3rd party tool. It shows MD5, SHA-1 check sums in one of file properties tabs. http://implbits.com/products/hashtab/




回答8:


7-Zip can be used to generate hashes for files, folders of files, and trees of folders of files. 7-Zip is small footprint and a very useful compression utility. http://7-zip.org/




回答9:


Download fciv.exe directly from http://www.microsoft.com/en-us/download/confirmation.aspx?id=11533

shell> fciv.exe [yourfile]

will give you md5 by default.

You can read up the help file fciv.exe -h




回答10:


Just to add another option for Windows users, the Get-FileHash PowerShell cmdlet can be used (https://technet.microsoft.com/en-us/library/dn520872.aspx).

Example usage: Get-FileHash MyImage.iso -Algorithm MD5

If all you're after is just the raw hash then: (Get-FileHash MyImage.iso -Algorithm MD5).Hash




回答11:


To calculate md5 of all the files in the current directory in windows 7

for %i in (*) DO CertUtil -hashfile %i MD5



回答12:


The Powershell utility Get-FileHash worked perfectly for me.

https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/get-filehash




回答13:


Best utility for Windows is HashCheck that is now on GitHub. https://github.com/gurnec/HashCheck/releases/tag/v2.4.0

Install HashCheck. Now right click on the file -> Create verification file. It will create a file.extension.md5 file with MD5 code in it.

Love it.




回答14:


Note that the above solutions will not tell you if your installation is correct only if your install.exe is correct (you can trust it to produce a correct install.)

You would need MD5 sums for each file/folder to test if the installed code has been messed with after the install completed.

WinMerg is useful to compare two installs (on two different machines perhaps) to see if one has been changed or why one is broken.




回答15:


for sure the certutil is the best approach but there's a chance to hit windows xp/2003 machine without certutil command.There makecab command can be used which has its own hash algorithm - here the fileinf.bat which will output some info about the file including the checksum.




回答16:


Hashing is a standalone application that performs MD5, SHA-1 and SHA-2 family. Built upon OpenSSL.




回答17:


I like to use HashMyFiles for windows.




回答18:


QuickHash an open source tool supporting MD5, SHA1, SHA256, SHA512 and available for the Linux, Windows, and Apple Mac.

https://sourceforge.net/projects/quickhash/




回答19:


In HPUX ( hp UNIX)

Please install the md5sum package on your UNIX machine for example, if there is a file called a.txt

shell > md5sum a.txt



回答20:


Just use win32 Checksum api. MD5 is native in Win32.



来源:https://stackoverflow.com/questions/478722/what-is-the-best-way-to-calculate-a-checksum-for-a-file-that-is-on-my-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!