code: def random_bits(bits_count):
  	
  	bytes_count = int(math.ceil(bits_count / 8))
  	random_value = int.from_bytes(os.urandom(bytes_count), byteorder=sys.byteorder)
  	result_bits = bytes_count * 8
  
  	if result_bits > bits_count:
  		random_value = (random_value >> (result_bits - bits_count))
  
  	return random_value
docs: Random generator (PyCrypto getrandbits wrapper). The result is a non-negative value.
  
  	:param bits_count: random bits to generate
  	:return: int