title: How can I calculate a hash for a filesystem-directory using Python?
body: <p>I'm using this code to calculate hash value for a file: </p>
  
  <pre><code>m = hashlib.md5()
  with open("calculator.pdf", 'rb') as fh:
      while True:
          data = fh.read(8192)
          if not data:
              break
          m.update(data)
      hash_value = m.hexdigest()
  
      print  hash_value
  </code></pre>
  
  <p>when I tried it on a folder "folder"I got </p>
  
  <pre><code>IOError: [Errno 13] Permission denied: folder
  </code></pre>
  
  <p>How could I calculate the hash value for a folder ?</p>