title: Python two complement checksum
body: <p>I am working in script in which I need to calculate the two's complement of certain hex value. </p>
  
  <p>I took this function from stackoverflow:</p>
  
  <pre><code>def checksum_calc(s):
      sum = 0
      for c in s:
          sum += ord(c)
      sum = -(sum % 256)
      return '%2X' % (sum &amp; 0xFF)
  </code></pre>
  
  <p>but if I introduced data like:</p>
  
  <pre><code>string = '\x00\x03\x03\xFF'
  </code></pre>
  
  <p>is correct but if I introduced it like this:</p>
  
  <pre><code>string = b'\x00\x03\x03\xFF'
  </code></pre>
  
  <p>I get incorrect checksum. </p>
  
  <p>Can you help me with this please?</p>