Ejemplo n.º 1
0
def test_bases():
    b36 = base36()
    b52 = base52()
    b56 = base56()
    b58 = base58()
    b62 = base62()
    b94 = base94()
Ejemplo n.º 2
0
from nose.tools import raises

from basehash import base58

bh58 = base58()
bh6 = base58(6)
bh10 = base58(10)


def test_base58_encode_with_1234567890_2t6V2H():
    assert bh58.encode(1234567890) == '2t6V2H'


def test_base58_decode_with_2t6V2H_1234567890():
    assert bh58.decode('2t6V2H') == 1234567890


def test_base58_hash_with_1234567890_10_SUcKRGPB1j():
    assert bh10.hash(1234567890) == 'SUcKRGPB1j'


def test_base58_unhash_with_SUcKRGPB1j_1234567890():
    assert bh10.unhash('SUcKRGPB1j') == 1234567890


def test_base58_maximum_value_with_6_38068692543():
    assert bh6.maximum == 38068692543


@raises(ValueError)
def test_base58_hash_fail_with_38068692544_6():
Ejemplo n.º 3
0
from basehash import HASH_LENGTH, base36, base52, base56, base58, base62, base94

base36 = base36()
base52 = base52()
base56 = base56()
base58 = base58()
base62 = base62()
base94 = base94()

# Base encode an integer/long
print(base36.encode(200))
print(base52.encode(200))
print(base56.encode(200))
print(base58.encode(200))
print(base62.encode(200))
print(base94.encode(200))

# Base decode encoded string.
print(base36.decode('5K'))
print(base52.decode('3r'))
print(base56.decode('5a'))
print(base58.decode('4T'))
print(base62.decode('3E'))
print(base94.decode('#-'))

# Base hash an integer/long
# Takes an option param, length, which is defaulted to
# basehash.base.HASH_LENGTH
print(base36.hash(200))
print(base52.hash(200))
print(base56.hash(200))
Ejemplo n.º 4
0
from nose.tools import raises

from basehash import base58


bh58 = base58()
bh6 = base58(6)
bh10 = base58(10)


def test_base58_encode_with_1234567890_2t6V2H():
    assert bh58.encode(1234567890) == '2t6V2H'


def test_base58_decode_with_2t6V2H_1234567890():
    assert bh58.decode('2t6V2H') == 1234567890


def test_base58_hash_with_1234567890_10_SUcKRGPB1j():
    assert bh10.hash(1234567890) == 'SUcKRGPB1j'


def test_base58_unhash_with_SUcKRGPB1j_1234567890():
    assert bh10.unhash('SUcKRGPB1j') == 1234567890


def test_base58_maximum_value_with_6_38068692543():
    assert bh6.maximum == 38068692543


@raises(ValueError)
Ejemplo n.º 5
0
from nose.tools import raises

from basehash import base58


base58 = base58()


def test_base58_encode_with_1234567890_2t6V2H():
    assert base58.encode(1234567890) == '2t6V2H'


def test_base58_decode_with_2t6V2H_1234567890():
    assert base58.decode('2t6V2H') == 1234567890


def test_base58_hash_with_1234567890_10_SUcKRGPB1j():
    assert base58.hash(1234567890, 10) == 'SUcKRGPB1j'


def test_base58_unhash_with_SUcKRGPB1j_1234567890():
    assert base58.unhash('SUcKRGPB1j') == 1234567890


def test_base58_maximum_value_with_6_38068692543():
    assert base58.maximum_value(6) == 38068692543


@raises(ValueError)
def test_base58_hash_fail_with_38068692544_6():
    assert base58.hash(38068692544, 6)