Exemple #1
0
def test_bases():
    b36 = base36()
    b52 = base52()
    b56 = base56()
    b58 = base58()
    b62 = base62()
    b94 = base94()
def get_identifiants():
    hash_fn = basehash.base94()
    with open("fichiers/identifiants.txt", "r") as identifiants:
        pseudo = "".join([
            chr(hash_fn.decode(char))
            for char in identifiants.readline().strip().split()
        ])
        mdp = "".join([
            chr(hash_fn.decode(char))
            for char in identifiants.readline().strip().split()
        ])
        cookie = "".join([
            chr(hash_fn.decode(char))
            for char in identifiants.readline().strip().split()
        ])

    return pseudo, mdp, cookie
def update_identifiants():
    def safe_input(prompt):
        if not sys.stdin.isatty():
            msg = input(prompt)
        else:
            msg = getpass(prompt=prompt)
        return msg

    pseudo = input("Pseudo: ")
    mdp = safe_input("Mot de passe: ")
    cookie_token = safe_input("Cookie d'auto-connection: ")

    hash_fn = basehash.base94()
    with open("fichiers/identifiants.txt", "w+") as identifiants:
        identifiants.write(" ".join(
            [hash_fn.encode(ord(char)) for char in pseudo]))
        identifiants.write("\n")
        identifiants.write(" ".join(
            [hash_fn.encode(ord(char)) for char in mdp]))
        identifiants.write("\n")
        identifiants.write(" ".join(
            [hash_fn.encode(ord(char)) for char in cookie_token]))
Exemple #4
0
from nose.tools import raises

from basehash import base94


bh94 = base94()
bh6 = base94(6)
bh10 = base94(10)


def test_base94_encode_with_1234567890_0mE5():
    assert bh94.encode(1234567890) == '0mE5{'


def test_base94_decode_with_0mE5_1234567890():
    assert bh94.decode('0mE5{') == 1234567890


def test_base94_hash_with_1234567890_10_Jl50():
    assert bh10.hash(1234567890) == 'J<-l50[.:%'


def test_base94_unhash_with_Jl50_1234567890():
    assert bh10.unhash('J<-l50[.:%') == 1234567890


def test_base94_maximum_value_with_6_689869781055():
    assert bh6.maximum == 689869781055


@raises(ValueError)
Exemple #5
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))
Exemple #6
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)