Encode an integer using Base58
771621
def b58encode_int(i, default_one=True):
    ''''''
    if not i and default_one:
        return alphabet[0]
    string = ""
    while i:
        i, idx = divmod(i, 58)
        string = alphabet[idx] + string
    return string
985959
protected static function base58_decode($base58)
    {
        $origbase58 = $base58;
        $return = "0";
        for ($i = 0; $i < strlen($base58); $i++) {
            $return = gmp_add(gmp_mul($return, 58), strpos(self::$B58_DIGITS, $base58[$i]));
        }
        $return = gmp_strval($return, 16);
        for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == "1"; $i++) {
            $return = "00" . $return;
        }
        if (strlen($return) % 2 != 0) {
            $return = "0" . $return;
        }
        return $return;
    }
229313
function encode(number) {
        if (number === 0) {
            return '';
        }

        var quotient = Math.floor(number / 64);
        var remainder = number % 64;

        var digit;
        if (remainder < 10) {
            digit = '' + remainder;
        }
        else if (remainder < 36) {
            digit = String.fromCharCode(remainder + 55);
        }
        else if (remainder < 62) {
            digit = String.fromCharCode(remainder + 61);
        }
        else if (remainder === 62) {
            digit = '-';
        }
        else if (remainder === 63) {
            digit = '_';
        }

        return encode(quotient) + '' + digit;
    }
909157
function encode(buf) {
	if (buf.length != 8) {
		throw new TypeError("Buffer must be length 8");
	}

	var num = new UInt64(buf.readUInt32BE(4), buf.readUInt32BE(0));
	var str = "";
	do {
		num.div(SIXTY_TWO);
		str = CHARS[num.remainder] + str;
	} while (num.greaterThan(ZERO));

	return str;
}
1325423
function encode5(n) {
  assert(0 <= n && n <= 0x3fffffff, ENCODE_OUTOFBOUNDS + n)
  // 30 bits -> 5 digits
  const lower = isolate(n, 0, 6)
  const aboveLower = isolate(n, 6, 6)
  const mid = isolate(n, 12, 6)
  const belowUpper = isolate(n, 18, 6)
  const upper = isolate(n, 24, 6)
  return encode(upper) + encode(belowUpper)
    + encode(mid) + encode(aboveLower) + encode(lower)
}
689578
def b58encode(v):
    

    long_value = 0
    for c in v:
        long_value = long_value * 256 + c

    result = ""
    while long_value >= __b58base:
        div, mod = divmod(long_value, __b58base)
        result = __b58chars[mod] + result
        long_value = div
    result = __b58chars[long_value] + result

    # Bitcoin does a little leading-zero-compression:
    # leading 0-bytes in the input become leading-1s
    nPad = 0
    for c in v:
        if c == 0:
            nPad += 1
        else:
            break

    return (__b58chars[0] * nPad) + result
692210
def encode_uvarint(n, data):
    ''''''
    if n < 0:
        raise ValueError('only support positive integer')
    while True:
        this_byte = n & 127
        n >>= 7
        if n == 0:
            data.append(this_byte)
            break
        data.append(this_byte | 128)
946877
def write_int64(self, value, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.pack('%sq' % endian, value)
1251145
function encodeInteger(value) {
	if (value === null) {
		return values.NULL;
	} else if (!isNaN(value) && parseInt(value)==value) {
		return value + "";
	} else {
		throw new Error('Invalid integer value "' + value + '"');
	}
}
737311
def encodeSemiOctets(number):
    
    if len(number) % 2 == 1:
        number = number + 'F' # append the "end" indicator
    octets = [int(number[i+1] + number[i], 16) for i in xrange(0, len(number), 2)]
    return bytearray(octets)
524840
def write_uint8(self, value, little_endian=True):
        
        if little_endian:
            endian = "<"
        else:
            endian = ">"
        return self.pack('%sB' % endian, value)
417439
def _encode(self, value):
        ""
        if isinstance(value, bytes):
            return value
        elif isinstance(value, (int, long)):
            value = str(value).encode('utf-8')
        elif isinstance(value, float):
            value = repr(value).encode('utf-8')
        elif not isinstance(value, basestring):
            value = str(value).encode('utf-8')
        else:
            value = value.encode('utf-8', 'strict')
        return value
803734
def encode_bu64(b):
    
    s = base64.standard_b64encode(b)
    s = s.rstrip('=')
    s = s.replace('+', '-')
    s = s.replace('/', '_')
    return s
934084
def encode(self, value, length, signed):
        '''
        
        '''
        if (length % 8 != 0) and self._mode:
            raise Exception('cannot use endianess for non bytes aligned int')
        pre = '' if signed else 'u'
        fmt = '%sint%s:%d=%d' % (pre, self._mode, length, value)
        return Bits(fmt)
626610
function convertToBase64(input) {
        var result = "";
        var charCodes = getExpandedCharCodes(input);
        var i = 0;
        var length = charCodes.length;
        var byte1, byte2, byte3, byte4;
        while (i < length) {
            // Convert every 6-bits in the input 3 character points
            // into a base64 digit
            byte1 = charCodes[i] >> 2;
            byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
            byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
            byte4 = charCodes[i + 2] & 63;
            // We are out of characters in the input, set the extra
            // digits to 64 (padding character).
            if (i + 1 >= length) {
                byte3 = byte4 = 64;
            }
            else if (i + 2 >= length) {
                byte4 = 64;
            }
            // Write to the output
            result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
            i += 3;
        }
        return result;
    }
263511
function encode(c) {
      return (c < 52 ? '' : encode(parseInt(c / 52))) +
        ((c = c % 52) > 25 ? String.fromCharCode(c + 39) : String.fromCharCode(c + 97));
    }
1269850
def base62_encode(cls, num):
        

        alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

        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)