def encodeBase58(num, alphabet=ALPHABET):
 if (num == 0):
  return alphabet[0]
 arr = []
 base = len(alphabet)
 while num:
  rem = (num % base)
  num = (num // base)
  arr.append(alphabet[rem])
 arr.reverse()
 return ''.join(arr)

def encodeBase58 ( num , alphabet = ALPHABET ) : if ( num == 0 ) : return alphabet [ 0 ] arr = [ ] base = len ( alphabet ) while num : rem = ( num % base ) num = ( num // base ) arr . append ( alphabet [ rem ] ) arr . reverse ( ) return '' . join ( arr )
encode a number in base x num: the number to encode alphabet: the alphabet to use for encoding .