How to use MD5 in Python?

Thread Solved

Join Date: Oct 2007
Posts: 68
Reputation: denniskhor is an unknown quantity at this point 
Solved Threads: 0
denniskhor denniskhor is offline Offline
Junior Poster in Training

How to use MD5 in Python?

 
0
  #1
Nov 11th, 2009
I want use MD5 to compare both folder in Python.

Following steps that i want to compare both folder by using MD5:

1. After all the files downloaded to folderA.
2. All the files inside folderA will copy to folderB.
3. Then MD5 will compare both folder is correct hash.
4. Then return True.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 1,012
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 165
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345
 
0
  #2
Nov 12th, 2009
Sooo. What work have you done? Its nice to see a base from which we can help you.
Make it idiot-proof, and someone will just make a better idiot
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,637
Reputation: vegaseat is a glorious beacon of light vegaseat is a glorious beacon of light vegaseat is a glorious beacon of light vegaseat is a glorious beacon of light vegaseat is a glorious beacon of light 
Solved Threads: 1085
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite
 
0
  #3
Nov 12th, 2009
Generally module md5 is used to encrypt strings/texts like passwords by making a unique check sum of the string. Once encrypted you cannot decrypt the resulting check sum back to the original string. The only way you can find out its contents is to encrypt another string and compare the md5 check sums.

Here is an example ...
  1. # Note that Python30 dropped md5 and uses hashlib.md5()
  2.  
  3. import md5
  4. mystring = "meet me at Karl's bar on Friday the tenth at 9PM"
  5. print( md5.md5(mystring).hexdigest() )
You can save the text to a file and attach the hexdigest string as a final line.
Last edited by vegaseat; Nov 17th, 2009 at 12:18 pm. Reason: ref to check sums
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 148
Reputation: mn_kthompson is an unknown quantity at this point 
Solved Threads: 33
mn_kthompson mn_kthompson is offline Offline
Junior Poster
 
0
  #4
Nov 12th, 2009
You're probably going to want to use some recursion when you're searching through the directories. If you copy subfolders you're going to want to know if the files in the subfolders have also copied properly.

You can see some examples of using recursion to list all the files in a directory and its subdirectories in this thread: http://www.daniweb.com/forums/thread234497.html
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: vansoking is an unknown quantity at this point 
Solved Threads: 1
vansoking vansoking is offline Offline
Newbie Poster
 
0
  #5
Nov 12th, 2009
Here is an example ...

http://effbot.org/librarybook/md5.htm
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 623 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC