import array


def toarr( data ):
    """Converts a string or byte array to a byte array.
    """
    if isinstance( data, array.array ):
      return data
    else:
      return array.array( 'B', data )