Whats more random, hashlib or urandom?

后端 未结 5 1358
旧时难觅i
旧时难觅i 2021-02-05 07:24

I\'m working on a project with a friend where we need to generate a random hash. Before we had time to discuss, we both came up with different approaches and because they are us

5条回答
  •  无人及你
    2021-02-05 08:12

    This solution:

    os.urandom(16).encode('hex')
    

    is the best since it uses the OS to generate randomness which should be usable for cryptographic purposes (depends on the OS implementation).

    random.random() generates pseudo-random values.

    Hashing a random value does not add any new randomness.

提交回复
热议问题