Will python SystemRandom / os.urandom always have enough entropy for good crypto

前端 未结 3 1324
走了就别回头了
走了就别回头了 2020-12-25 13:12

I have a password generator:

import random, string

def gen_pass():
    foo = random.SystemRandom()
    length = 64
    chars = string.letters + string.digit         


        
3条回答
  •  攒了一身酷
    2020-12-25 13:55

    /dev/random/ will block on read if it needs more entropy. /dev/urandom/ won't. So yes, if you use it too fast you'll run low on entropy. Probably still quite hard to guess, of course, but if you're really concerned you can read bytes from /dev/random/ instead. Ideally, with a non-blocking read loop and a progress indicator so you can move the mouse around and generate entropy if needed.

提交回复
热议问题