docs: def b58check_encode(bin_s, version_byte=0):
      """ Takes in a binary string and converts it to a base 58 check string. """
      # append the version byte to the beginning
      bin_s = chr(int(version_byte)) + bin_s
      # calculate the number of leading zeros
      num_leading_zeros = len(re.match(r'^\x00*', bin_s).group(0))
      # add in the checksum add the end
      bin_s = bin_s + bin_checksum(bin_s)
      # convert from b2 to b16
      hex_s = hexlify(bin_s)
      # convert from b16 to b58
      b58_s = change_charset(hex_s, HEX_KEYSPACE, B58_KEYSPACE)
  
      return B58_KEYSPACE[0] * num_leading_zeros + b58_s