Is adding the message itself to the hash stronger than the hash

Viewed 57

I've been reading up on how Python constructs a random seed from the user input. The relevant bit of code is shown below

    elif version == 2 and isinstance(a, (str, bytes, bytearray)):
        if isinstance(a, str):
            a = a.encode()
        a = int.from_bytes(a + _sha512(a).digest(), 'big')

In particular my question is why the code takes the user input itself, and adds it to the hash, instead of just using the hash itself. Does this provide a better seed, or has other programming benefits? The alternative in my view would just be to use the digest from the hash

    a = int.from_bytes(_sha512(a).digest(), 'big')

Python uses the mersenne twister as its random number generator, which needs to be properly initialized. I fail to see how a + _sha512(a).digest() provides a better seed over just a_sha512(a).digest()

0 Answers
Related