Ejemplo n.º 1
0
def test_arbitrary_hash():
    """Let's try the hasher with a lot of hashes, say 75 maybe?"""
    all_ascii = string.ascii_letters + string.digits
    for i in range(100):
        inbytes = ''.join(random.choice(all_ascii) for _ in range(500)).encode()
        testhash = md5._hash(io.BytesIO(inbytes))
        echo = subprocess.Popen(('/bin/echo', '-e', '-n', inbytes), stdout=subprocess.PIPE)
        syshash = subprocess.check_output('md5sum', stdin=echo.stdout).decode().split(' ')[0] # eww
        assert syshash == testhash
Ejemplo n.º 2
0
def test_arbitrary_hash():
    """Let's try the hasher with a lot of hashes, say 75 maybe?"""
    all_ascii = string.ascii_letters + string.digits
    for i in range(100):
        inbytes = ''.join(random.choice(all_ascii)
                          for _ in range(500)).encode()
        testhash = md5._hash(io.BytesIO(inbytes))
        echo = subprocess.Popen(('/bin/echo', '-e', '-n', inbytes),
                                stdout=subprocess.PIPE)
        syshash = subprocess.check_output(
            'md5sum', stdin=echo.stdout).decode().split(' ')[0]  # eww
        assert syshash == testhash
Ejemplo n.º 3
0
def test_hasher():
    test, result = io.BytesIO(b'hello, world!\n'), '910c8bc73110b0cd1bc5d2bcae782511'
    assert md5._hash(test) == result
Ejemplo n.º 4
0
def test_hasher():
    test, result = io.BytesIO(
        b'hello, world!\n'), '910c8bc73110b0cd1bc5d2bcae782511'
    assert md5._hash(test) == result