title: Compare 2 sha512 hash passed as input in python
body: <p>I have 2 hashes which i need to compare.1 is coming from an API, other i have calculated internally <br />
  I am aware that 2 <code>sha512</code> can be compared using </p>
  
  <pre><code>input1.digest() == input2.digest()
  </code></pre>
  
  <p>where both inputs are <code>sha512</code> hash.My problem here is that since i am getting 1 of them from an API, it is of <code>string</code> format and strings don't have <code>digest</code> :</p>
  
  <blockquote>
    <p>*** AttributeError: 'str' object has no attribute 'digest'</p>
  </blockquote>
  
  <p>I thought this would work :</p>
  
  <pre><code>if(calculated_hash != input_hash):
      return False
  return True
  </code></pre>
  
  <p>how hash is getting generated internally for one of the test cases:</p>
  
  <pre><code>hash_val = sha512(parameters.encode('utf-8') + salt.encode('utf-8')).hexdigest()
  </code></pre>
  
  <p>But since hash is new every-time, this is not working.</p>
  
  <p>How can i compare these 2 hashes under given scenario?</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>there was a dynamic timestamp in input because of which there was a difference in hash recieved vc hash generated from params recived.<strong>But</strong>, i am still getting the value as False on comparing <code>hexdigest</code>!! :\</p>