Returns a tuple of:
    (64-char hex key, 2-char hex prefix for key, if it was compressed)
190689
def wiftohex(wifkey):
    '''
    
    '''

    iscompressed = False
    wifkey = normalize_input(wifkey)
    assert len(wifkey) == 50 or len(wifkey) == 51 or len(wifkey) == 52
    for c in wifkey:
        if c not in b58_digits:
            raise Exception("Not WIF")
    key = b58d(wifkey)
    prefix, key = key[:2], key[2:] 
    if len(key) == 66:
        assert key[-2:] == '01'
        key = key[:-2]
        iscompressed = True
    assert len(key) == 64
    return key, prefix, iscompressed
692878
def convert_bytes(n):
    
    symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
    prefix = {}
    for i, s in enumerate(symbols):
        prefix[s] = 1 << (i + 1) * 10
    for s in reversed(symbols):
        if n >= prefix[s]:
            value = float(n) / prefix[s]
            return '%.1f%s' % (value, s)
    return "%sB" % n
740556
def wrap_key(self, key):
        
        return tuple(np.round(
            self.integer_cell.shortest_vector(key)
        ).astype(int))
256610
public static String generateKey() {
		byte[] bytes = new byte[32];
		getRandom().nextBytes(bytes);
		char[] chars = new char[64];
		for(int c=0;c<32;c++) {
			byte b = bytes[c];
			chars[c*2]=hexChars[(b&255)>>>4];
			chars[c*2+1]=hexChars[b&15];
		}
		return new String(chars);
	}
944460
def compress(x, y):
    
    polarity = "02" if y % 2 == 0 else "03"

    wrap = lambda x: x
    if not is_py2:
        wrap = lambda x: bytes(x, 'ascii')

    return unhexlify(wrap("%s%0.64x" % (polarity, x)))
329804
def unhex(inp):
    ''''''
    res = inp.split(r'\x')
    for i in xrange(1, len(res)):
        item = res[i]
        try:
            res[i] = _hextochr[item[:2]] + item[2:]
        except KeyError:
            res[i] = '%' + item
        except UnicodeDecodeError:
            res[i] = unichr(int(item[:2], 16)) + item[2:]
    return ''.join(res)
907622
def get_uncompressed_private_and_public_keys( privkey_str ):
    
    if not isinstance(privkey_str, (str, unicode)):
        raise ValueError("private key given is not a string")

    pk = ecdsa_private_key(str(privkey_str))
    pk_hex = pk.to_hex()

    # force uncompressed
    if len(pk_hex) > 64:
        if pk_hex[-2:] != '01':
            raise ValueError("private key does not end in '01'")

        pk_hex = pk_hex[:64]

    pubk_hex = ecdsa_private_key(pk_hex).public_key().to_hex()
    return pk_hex, pubk_hex
1049547
def hex_color_to_tuple(hex):
    
    hex = hex[1:]
    length = len(hex) // 2
    return tuple(int(hex[i*2:i*2+2], 16) for i in range(length))
198003
def compressed(self):
        
        order = ecdsa.SECP256k1.generator.order()
        p = ecdsa.VerifyingKey.from_string(
            compat_bytes(self), curve=ecdsa.SECP256k1).pubkey.point
        x_str = ecdsa.util.number_to_string(p.x(), order)
        # y_str = ecdsa.util.number_to_string(p.y(), order)
        compressed = hexlify(
            compat_bytes(chr(2 + (p.y() & 1)), 'ascii') + x_str).decode(
            'ascii')
        return (compressed)
786128
def rc4(data, key):
    """"""
    S, j, out = list(range(256)), 0, []

    for i in range(256):
        j = (j + S[i] + ord(key[i % len(key)])) % 256
        S[i], S[j] = S[j], S[i]

    i = j = 0
    for ch in data:
        i = (i + 1) % 256
        j = (j + S[i]) % 256
        S[i], S[j] = S[j], S[i]
        out.append(chr(ord(ch) ^ S[(S[i] + S[j]) % 256]))

    return "".join(out)
84052
def unCompressed(self):
        
        public_key = repr(self._pk)
        prefix = public_key[0:2]
        if prefix == "04":
            return public_key
        assert prefix == "02" or prefix == "03"
        x = int(public_key[2:], 16)
        y = self._derive_y_from_x(x, (prefix == "02"))
        key = '04' + '%064x' % x + '%064x' % y
        return key
977422
def bin2hex(s):
    
    padding_length = (8 - len(s) % 8) % 8
    # 从前往后解码，不足8个的，在后面补0
    encode_str = '%s%s' % (s, '0' * padding_length)
    # 解码后是 0xab1234，需要去掉前面的 0x
    return hex(int(encode_str, 2))[2:].rstrip('L')
272546
def get_witness_for_key_prefix(db, node_hash, key):
    
    validate_is_bytes(key)

    return tuple(_get_witness_for_key_prefix(db, node_hash, encode_to_bin(key)))
838301
def str2rsi(key):
    
    rlzi, sid, imt = key.split('/')
    return int(rlzi[4:]), int(sid[4:]), imt
1211466
private static String[] decodeKey(Key k) {
    String s = new String((k.isChunkKey()) ? Arrays.copyOfRange(k._kb, Vec.KEY_PREFIX_LEN, k._kb.length):k._kb);
    return decode(s);
  }
711743
def fingerprint_from_raw_ssh_pub_key(key):
    
    fp_plain = hashlib.md5(key).hexdigest()
    return ':'.join(a + b for a, b in zip(fp_plain[::2], fp_plain[1::2]))
1250849
def compress(pub):
    '''
    
    '''

    x = pub[2:66]
    y = pub[66:]
    if int(y,16) % 2:
        o = str('03') + str(x)
    else:
        o = str('02') + str(x)
    return o