Jump To Content
Computer Science

Computer Science


Using md5 sums

Once you have downloaded a file from the internet, it is always nice to check the integrity of the file to ensure that it contains what it is meant to contain.  No more and no less.

That is the purpose of md5.

A hash (a long number) is created from the code that comprises the program that you want to download.  It can also be referred to as a key or a hash key.

That hash is created by using a program that manipulates the code through specific steps.  Those steps are called an algorithm.  And the hash is posted on or near the place where the program is downloaded from the server.  Not all programs have md5 sums, but if one does, it is nice to be able to know how to use it.

After the program is on your computer, you create a hash using a program that takes the new unopened, unexecuted download through the same steps (algorithm) that the creator (or support staff) did at the server end.  The program I use on Windows is md5sums.  http://www.pc-tools.net/win32/md5sums/

It is a zipped file.  I will write a tutorial on unzipping files.

The program md5sums works by creating a hash for any program whose icon is dragged over the md5sums icon.

For example:

I download ruby.  I save it in my downloads file in a new folder called ruby.  Before I open the ruby download, I want to make sure the program is intact.  So I check it with md5sums.

I copy the md5sums.exe file from it's home in the md5sums folder in downloads.  Then I paste it in the ruby folder under the ruby186-26.exe file.  Then I drag the ruby186-26.exe file over the md5sums.exe icon.  A command line window will appear.  Don't be frightened, you don't have to do anything except read the numbers.  On the ride side of the screen there will be a long number, like this:
 4d512cea917dd1cf010aaab2e6d286be
(note: this is not the hash for ruby186-26.exe)
and that is the md5 key.  Compare the number in the terminal window to the number on the site for the program you downloaded.

If the two hashs match, your download is intact and you can unpack and execute according to instructions.

If the hashs do not match, do not use the program.  If you are inclined, contact the providers of said program and inform them that your hash did not match theirs.  You may decide to include your hash for their reference.

You close the terminal window that calculated the hash by pressing ENTER as the instructions suggest or by clicking the "X" in the top right corner of the window.

I hope this helps you to understand the meaning and use of md5.

agoucher
  • Authority 229
Post Body
agoucher said:

Or, you could use python.

import hashlib

i = hashlib.md5()

i.update(open(“zsi-2.0.pdf”, “r”).read()) #change this to be your file

print i.hexdigest()

7350668e41ed1395a8d5ce151e5d0644

Note that this will put the entire file into memory. Don’t try this with multiple gig log files.

  • Quote
  • Posted 5 months ago.
Carsten
  • Authority 299
Post Body
Carsten said:

Or with Ruby…


require 'digest'
puts Digest::MD5.hexdigest(File.read('some_file.png'))

And if you don’t want to put the entire file into memory, try this out:


hash = Digest::MD5.new

File.open('some_file.iso', 'r') do |file|
  hash.update(file.read(16384)) until file.eof
end

puts hash.hexdigest
  • Quote
  • Posted 4 months ago.
barun2008
  • Authority 16
Post Body
barun2008 said:

i am unable to understand this.please anyone explain and send it to my mail : barunsarkarindia1@gmail.com

  • Quote
  • Posted about 1 month ago.
Carsten
  • Authority 299
Post Body
Carsten said in response to:
barun2008
barun2008’s post:
Citation Body

i am unable to understand this.please anyone explain and send it to my mail : barunsarkarindia1@gmail.com

Check this out.

  • Quote
  • Posted about 1 month ago.
  • Your comment will be modifiable for 10 minutes after posted.

Page Author

Avatar
anteaya
Name
anteaya

From Here You Can…

Information

  • 1362 Views
  • 4 Comments
  • Ratings Likes 5 Negative 0

Most Recent Related Content