Decode a Base58 encoded string
552588
def b58decode(v):
    ''''''
    v = v.rstrip()
    v = scrub_input(v)

    origlen = len(v)
    v = v.lstrip(alphabet[0:1])
    newlen = len(v)

    acc = b58decode_int(v)

    result = []
    while acc > 0:
        acc, mod = divmod(acc, 256)
        result.append(mod)

    return (b'\0' * (origlen - newlen) + bseq(reversed(result)))
528202
def b58encode(v):
    ''''''
    if not isinstance(v, bytes):
        raise TypeError("a bytes-like object is required, not '%s'" %
                        type(v).__name__)

    origlen = len(v)
    v = v.lstrip(b'\0')
    newlen = len(v)

    p, acc = 1, 0
    for c in iseq(reversed(v)):
        acc += p * c
        p = p << 8

    result = b58encode_int(acc, default_one=False)

    return (alphabet[0] * (origlen - newlen) + result)
150570
def encode(data, checksum=True):
    """"""

    if checksum:
        data = data + utils.hash256(data)[:4]
    v, prefix = to_long(256, lambda x: x, iter(data))
    data = from_long(v, prefix, BASE58_BASE, lambda v: BASE58_ALPHABET[v])
    return data.decode("utf8")
838573
def Decode(self, encoded_data):
    
    try:
      # TODO: replace by libuna implementation or equivalent. The behavior of
      # base64.b64decode() does not raise TypeError for certain invalid base64
      # data e.g. b'\x01\x02\x03\x04\x05\x06\x07\x08' these are silently
      # ignored.
      decoded_data = base64.b64decode(encoded_data)
    except (TypeError, binascii.Error) as exception:
      raise errors.BackEndError(
          'Unable to decode base64 stream with error: {0!s}.'.format(
              exception))

    return decoded_data, b''
698184
function decode (str) {
  if (!isValid(str)) throw new Error('baseURL#decode: str not valid baseURL string');

  var bits = '';
  // Decode
  for (var i = 0; i < str.length; i++) {
    bits += indexOfBits(str[i]);
  }
  return bits;
}
767994
def decode(cls, s):
        
        b = ByteString(s)
        bd = base64.b64decode(b)
        return String(bd)
523456
function b64EncodeUnicode(str) {
  return btoa(
    encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
      function toSolidBytes(match, p1) {
        return String.fromCharCode('0x' + p1);
      }));
}
1162723
def b58decode_int(v):
    ''''''

    if not isinstance(v, str):
        v = v.decode('ascii')

    decimal = 0
    for char in v:
        decimal = decimal * 58 + alphabet.index(char)
    return decimal
197293
def encode(data: Union[str, bytes]) -> str:
        
        return ensure_str(base58.b58encode(ensure_bytes(data)))
786284
def decode_base58_address(addr)
      hex = Base58.decode(addr)
      if hex.size == 50 && calc_checksum(hex[0...-8]) == hex[-8..-1]
        raise 'Invalid version bytes.' unless [Bitcoin.chain_params.address_version, Bitcoin.chain_params.p2sh_version].include?(hex[0..1])
        [hex[2...-8], hex[0..1]]
      else
        raise 'Invalid address.'
      end
    end
201476
def b58decode(v: str) -> bytes:
    ''''''

    origlen = len(v)
    v = v.lstrip(alphabet[0])
    newlen = len(v)

    p, acc = 1, 0
    for c in v[::-1]:
        acc += p * alphabet.index(c)
        p *= 58

    result = []
    while acc > 0:
        acc, mod = divmod(acc, 256)
        result.append(mod)

    return (bseq(result) + b'\0' * (origlen - newlen))[::-1]
711446
function decode (string) {
  var body = Buffer.from(string, 'base64').toString('utf8')
  return JSON.parse(body)
}
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
280268
def decode_cp1252(str)
      array_latin9 = str.unpack('C*')
      array_enc = []
      array_latin9.each do |num|
        case num
          # characters that added compared to iso-8859-1
        when 0x80; array_enc << 0x20AC # 0xe2 0x82 0xac
        when 0x82; array_enc << 0x201A # 0xe2 0x82 0x9a
        when 0x83; array_enc << 0x0192 # 0xc6 0x92
        when 0x84; array_enc << 0x201E # 0xe2 0x82 0x9e
        when 0x85; array_enc << 0x2026 # 0xe2 0x80 0xa6
        when 0x86; array_enc << 0x2020 # 0xe2 0x80 0xa0
        when 0x87; array_enc << 0x2021 # 0xe2 0x80 0xa1
        when 0x88; array_enc << 0x02C6 # 0xcb 0x86
        when 0x89; array_enc << 0x2030 # 0xe2 0x80 0xb0
        when 0x8A; array_enc << 0x0160 # 0xc5 0xa0
        when 0x8B; array_enc << 0x2039 # 0xe2 0x80 0xb9
        when 0x8C; array_enc << 0x0152 # 0xc5 0x92
        when 0x8E; array_enc << 0x017D # 0xc5 0xbd
        when 0x91; array_enc << 0x2018 # 0xe2 0x80 0x98
        when 0x92; array_enc << 0x2019 # 0xe2 0x80 0x99
        when 0x93; array_enc << 0x201C # 0xe2 0x80 0x9c
        when 0x94; array_enc << 0x201D # 0xe2 0x80 0x9d
        when 0x95; array_enc << 0x2022 # 0xe2 0x80 0xa2
        when 0x96; array_enc << 0x2013 # 0xe2 0x80 0x93
        when 0x97; array_enc << 0x2014 # 0xe2 0x80 0x94
        when 0x98; array_enc << 0x02DC # 0xcb 0x9c
        when 0x99; array_enc << 0x2122 # 0xe2 0x84 0xa2
        when 0x9A; array_enc << 0x0161 # 0xc5 0xa1
        when 0x9B; array_enc << 0x203A # 0xe2 0x80 0xba
        when 0x9C; array_enc << 0x0152 # 0xc5 0x93
        when 0x9E; array_enc << 0x017E # 0xc5 0xbe
        when 0x9F; array_enc << 0x0178 # 0xc5 0xb8
        else
          array_enc << num
        end
      end
      array_enc.pack('U*')
    end
700219
def decode(string, base):
    

    base = int(base)
    code_string = get_code_string(base)
    result = 0
    if base == 16:
        string = string.lower()
    while len(string) > 0:
        result *= base
        result += code_string.find(string[0])
        string = string[1:]
    return result
818245
public function decode($base58)
    {
        // Type Validation
        if (is_string($base58) === false) {
            throw new InvalidArgumentException('Argument $base58 must be a string.');
        }

        // If the string is empty, then the decoded string is obviously empty
        if (strlen($base58) === 0) {
            return '';
        }

        $indexes = array_flip(str_split($this->alphabet));
        $chars = str_split($base58);

        // Check for invalid characters in the supplied base58 string
        foreach ($chars as $char) {
            if (isset($indexes[$char]) === false) {
                throw new InvalidArgumentException('Argument $base58 contains invalid characters. ($char: "'.$char.'" | $base58: "'.$base58.'") ');
            }
        }

        // Convert from base58 to base10
        $decimal = $indexes[$chars[0]];

        for ($i = 1, $l = count($chars); $i < $l; $i++) {
            $decimal = bcmul($decimal, $this->base);
            $decimal = bcadd($decimal, $indexes[$chars[$i]]);
        }

        // Convert from base10 to base256 (8-bit byte array)
        $output = '';
        while ($decimal > 0) {
            $byte = bcmod($decimal, 256);
            $output = pack('C', $byte) . $output;
            $decimal = bcdiv($decimal, 256, 0);
        }

        // Now we need to add leading zeros
        foreach ($chars as $char) {
            if ($indexes[$char] === 0) {
                $output = "\x00" . $output;
                continue;
            }
            break;
        }

        return $output;
    }
369106
def byte_str(s="", encoding="utf-8", input_encoding="utf-8", errors="strict"):
    
    assert isinstance(s, basestring)
    if isinstance(s, unicode):
        return s.encode(encoding, errors)
    if s and encoding != input_encoding:
        return s.decode(input_encoding, errors).encode(encoding, errors)
    return s