title: Python md5 password value
body: <p>I have this change password request form.In which the user enter their oldpasswords.</p>
  
  <p>this oldpassword is the md5 format.</p>
  
  <p>How to compare the md5 value from db to the oldpassword entered by user</p>
  
  <pre><code> import md5
  
   oldpasswd_byuser=str("tom")
   oldpasswd_db="sha1$c60da$1835a9c3ccb1cc436ccaa577679b5d0321234c6f"
   opw=     md5.new(oldpasswd_byuser)
   #opw=     md5.new(oldpasswd_byuser).hexdigest()
   if(opw ==      oldpasswd_db):
      print "same password"
   else:
       print "Invalid password" 
  </code></pre>