Return Base58 string from data

        :param data: Bytes or string data
197293
def encode(data: Union[str, bytes]) -> str:
        
        return ensure_str(base58.b58encode(ensure_bytes(data)))
1366832
def _decode(self, data):
        
        if self.encoding:
            data = data.decode(self.encoding, 'replace')
        return data
709561
def _wrap_data(data: Union[str, bytes]):
        
        MsgType = TextMessage if isinstance(data, str) else BytesMessage
        return MsgType(data=data, frame_finished=True, message_finished=True)
558496
def _decode(data):
    
    if not isinstance(data, bytes_types):
        data = six.b(str(data))
    return base64.b64decode(data.decode("utf-8"))
669035
def bytes_from_decode_data(s):
    
    if isinstance(s, (str, unicode)):
        try:
            return s.encode('ascii')
        except UnicodeEncodeError:
            raise NotValidParamError(
                'String argument should contain only ASCII characters')
    if isinstance(s, bytes_types):
        return s
    try:
        return memoryview(s).tobytes()
    except TypeError:
        raise suppress_context(
            TypeError(
                'Argument should be a bytes-like object or ASCII string, not '
                '{!r}'.format(s.__class__.__name__)))
247974
def data_for_base58check_encoding
      data = BTC::Data.data_from_bytes([self.version]) + @data
      if @public_key_compressed
        data += BTC::Data.data_from_bytes([0x01])
      end
      return data
    end
556429
def string(self, *args):
        
        data = self.bytes(*args)
        if data is not None:
            return data.rstrip(b"\x00").decode('utf-8')
178038
def decode(data):
    
    data = ensure_bytes(data, 'utf8')
    codec = get_codec(data)
    return codec.converter.decode(data[CODE_LENGTH:])
110032
def to_python(self, data):
        
        if data is None:
            return ''
        if isinstance(data, unicode):
            data = data.encode(DEFAULT_ENCODING)
        else:
            data = str(data)
        return data
79625
def decode_arr(data):
    """"""
    data = data.encode('utf-8')
    return frombuffer(base64.b64decode(data), float64)
1099914
def b58encode(b, errors='strict'):
    ""
    len_ = len(b)

    # Convert big-endian bytes to integer
    n = BigInteger.deserialize(BytesIO(b), len_)

    # Divide that integer into base58
    res = []
    while n > 0:
        n, r = divmod (n, 58)
        res.append(b58digits[r])
    res = ''.join(res[::-1])

    # Encode leading zeros as base58 zeros
    pad = 0
    for c in b:
        if c == six.int2byte(0): pad += 1
        else: break
    return (b58digits[0] * pad + res, len_)
1150716
def serialize_b58(self, private=True):
        """"""
        return ensure_str(
            base58.b58encode_check(unhexlify(self.serialize(private))))
755525
def byte2bit_string(data):
    
    if isinstance(data, basestring):
        assert len(data) == 1
        data = ord(data)

    bits = '{0:08b}'.format(data)
    bits = bits[::-1]
    return bits
1184064
def _unpack_string(self, data):
        
        # Get the size of the string
        result, data = self._unpack("<H", data)
        size = result[0]

        # Read it
        string_bytes = data[:size]

        # Convert it
        return to_unicode(string_bytes), data[size:]
664056
def decode_base64_dict(data):
    ''' 

    '''
    b64 = base64.b64decode(data['__ndarray__'])
    array = np.copy(np.frombuffer(b64, dtype=data['dtype']))
    if len(data['shape']) > 1:
        array = array.reshape(data['shape'])
    return array
106520
def hexdigest(self, data=None):
        
        from base64 import b16encode
        if pyver == 2:
            return b16encode(self.digest(data))
        else:
            return b16encode(self.digest(data)).decode('us-ascii')
227810
def to_bytes(data):
    
    if isinstance(data, six.string_types) and not isinstance(data, bytes):
        return codecs.encode(data, TEXT_ENCODING)
    return data