How to use the base58.b58decode_int function in base58

To help you get started, we’ve selected a few base58 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keis / base58 / test_base58.py View on Github external
def test_simple_integers():
    for idx, char in enumerate(BITCOIN_ALPHABET):
        charbytes = bytes([char])
        assert_that(b58decode_int(charbytes), equal_to(idx))
        assert_that(b58encode_int(idx), equal_to(charbytes))
github keis / base58 / test_base58.py View on Github external
def test_large_integer():
    number = 0x111d38e5fc9071ffcd20b4a763cc9ae4f252bb4e48fd66a835e252ada93ff480d6dd43dc62a641155a5  # noqa
    assert_that(b58decode_int(BITCOIN_ALPHABET), equal_to(number))
    assert_that(b58encode_int(number), equal_to(BITCOIN_ALPHABET[1:]))
github swtcpro / jingtum-lib-python / src / base / keypairs.py View on Github external
def __decode(version, input):
    """
    decode encoded input,
    too small or invalid checksum will throw exception
    :param version:
    :param input:
    :return:
    """
    bytes = base58.b58decode_int(input)
    if bytes is not None or bytes[0] != version or bytes.__len__() < 5:
        raise Exception('invalid input size')
    computed = sha256(sha256(bytes[0, -4]))[0, 4]
    checksum = bytes[-4]
    for i in range(0, 4):
        if computed[i] != checksum[i]:
            raise Exception('invalid checksum')
    return bytes[1, -4]