title: unsupported operand type(s) for ^: 'byte array' and 'int' (bitwise operator)
body: <p>I'm trying to make some calculations with a <code>bytearray</code> for a hashing algorithm but keep getting an error about <code>^</code> operand types.  I already made some other methods that seem to work well, but with this method it keeps getting an error.  Below is the code: </p>
  
  <pre><code>def showstate(a):
      i = 0
      buf = bytearray()
      width = 17
      print (type(a))
      while i &lt; 8 * width:
          buf.append(buf ^  (1 and a[i])&lt;&lt;(7-(i%8)))
          #buf ^= (1 and a[i])&lt;&lt;(7-(i%8))
          #print ("absc")
          if  (((i%8) == 7) and (i)):
              print("%02x"%buf, end = '')
              buf = 0
          i += 1
  </code></pre>
  
  <p>I already tried to look the type of data that <code>a</code> had -- it says <code>bytearray</code>  I don't see any problem with the calculation of <code>buf</code>. Why does it always error with: </p>
  
  <pre><code>TypeError: unsupported operand type(s) for ^: 'bytearray' and 'int'
  
  </code></pre>