title: XOR bytes in Python3
body: <p>On trying to xor bytes in python3:</p>
  
  <pre><code>import os,binascii
  import numpy as np
  
  def xor_byte_hex_strings(a, b) :
      return bytes(x ^ y for x, y in zip(a, b))
  
  
  number_of_bytes = 2
  
  random_bytes = []
  
  random_bytes_str = binascii.b2a_hex(os.urandom(number_of_bytes))
  random_bytes.append(random_bytes_str)
  
  print(random_bytes_str)
  print(bytearray(random_bytes_str))
  
  random_bytes_str = binascii.b2a_hex(os.urandom(number_of_bytes))
  random_bytes.append(random_bytes_str)
  
  resultant = xor_byte_hex_strings(random_bytes[0], random_bytes[1])
  print("resultant = ", bytearray(resultant))
  print(random_bytes)
  
  resultant = xor_byte_hex_strings(random_bytes[1], resultant)
  print(resultant)
  </code></pre>
  
  <p>The result is b'\x03\x03\x0cU' instead of b'13ce.
  How do we convert the format from b'\x03\x03\x0cU' to b'13ce?</p>