title: Calculate hash of object , python
body: <p>I have a class with string data, and I'm supposed to calculate hash of the whole object using <code>hashlib.sha256()</code> . 
  I was not directly able to get hash with 
  block c for example</p>
  
  <pre><code>Hash = hashlib.sha256(c.encode()).digest()
  </code></pre>
  
  <p>I want to calculate hash of the whole object,I was suggested to have a function in the class such that it returns hash of data inside it . Is it same as has of whole block ? What is better implementation?</p>