title: Using a password dictionary to decrypt leaked passwords
body: <p>I'm currently learning about how hackers can decrypt files containing dumps of hashed passwords by using password dictionaries which contain a list of common passwords and comparing the hashed value of those with the ones in the password dump file. I'm testing essentially that method of decryption in the following python function using the password dictionary rockyou.txt from kali linux (which I've seen good reviews about):</p>
  <pre><code>def decrypt_pass(dict_file,pword_file):
      eh_file = open(&quot;eh_passwords.txt&quot;,&quot;w&quot;)
      pFile = open(pword_file,&quot;r&quot;)
      dFile = open(dict_file,&quot;r&quot;)     
  
      for eachLine in pFile:
          for line in dFile:
              dFileHash = hashlib.md5(line.strip()).hexdigest()
              
              if eachLine.strip() == dFileHash:
                  eh_file.write(line + &quot;\n&quot;)
  </code></pre>
  <p>This function seems to work When I use two test files, one containing about 12 hashed passwords and the other one containing a small list of common passwords. However, when I run the function using the rockyou.txt and a password dump file (like the one from the linkedin or eHarmony hacks), the function doesn't write anything to the output file.</p>
  <p><strong>Is this happening because the rockyou.txt file is too large for this kind of brute force approach or is it that there are not any passwords that are common between the files? If I'm approaching this from the wrong angle, how should I go about doing the decryption more efficiently?</strong></p>
  <h3>EDIT</h3>
  <p><strong>Below are the two sample files that I used to test the code. The correct matches were found when using these files.</strong></p>
  <p><strong>test dictionary file</strong></p>
  <pre><code>monkey
  lovely
  jessica
  654321
  michael
  ashley
  123456
  12345
  123456789
  password
  iloveyou
  princess
  1234567
  rockyou
  12345678
  abc123
  </code></pre>
  <p><strong>test password dump file (using md5 hash)</strong></p>
  <pre><code>e10adc3949ba59abbe56e057f20f883e
  827ccb0eea8a706c4c34a16891f84e7b
  25f9e794323b453885f5181f1b624d0b
  5f4dcc3b5aa765d61d8327deb882cf99
  f25a2fc72690b780b2a14e140ef6a9e0
  8afa847f50a716e64932d995c8e7435a
  fcea920f7412b5da7be0cf42b8c93759
  f806fc5a2a0d5ba2471600758452799c
  25d55ad283aa400af464c76d713c07ad
  e99a18c428cb38d5f260853678922e03
  fc63f87c08d505264caba37514cd0cfd
  aa47f8215c6f30a0dcdb2a36a9f4168e
  </code></pre>