def P_hash(hashModule, secret, seed, length):
    bytes = createByteArrayZeros(length)
    secret = bytesToString(secret)
    seed = bytesToString(seed)
    A = seed
    index = 0
    while 1:
        A = hmac.HMAC(secret, A, hashModule).digest()
        output = hmac.HMAC(secret, A+seed, hashModule).digest()
        for c in output:
            if index >= length:
                return bytes
            bytes[index] = ord(c)
            index += 1
    return bytes
dataset/ETHPy150Open CollabQ/CollabQ/vendor/gdata/tlslite/mathtls.py/P_hash/original