title: Python: TypeError: Unicode-objects must be encoded before hashing
body: <p>I am trying to read in a file of passwords. Then I am trying to compute the hash for each password and compare it to a hash I already have to determine if I have discovered the password. However the error message I keep getting is "TypeError: Unicode-objects must be encoded before hashing". Here is my code:</p>
  
  <pre><code>from hashlib import sha256
  
  with open('words','r') as f:
      for line in f:
  
          hashedWord = sha256(line.rstrip()).hexdigest()
  
          if hashedWord == 'ca52258a43795ab5c89513f9984b8f3d3d0aa61fb7792ecefe8d90010ee39f2':
              print(line + "is one of the words!")
  </code></pre>
  
  <p>Can anyone please help and provide an explanation?</p>