草庐IT

SystemRandom

全部标签

python - 使用哪个更安全? uuid,binascii.hexlify(os.urandom()) 或 random.SystemRandom()?

我想创建独一无二的和对于自己注册该服务的用户。所以,我一直在寻找相同的东西并想出了这些选项:uuidbinascii.hexlify(os.urandom(x))random.SystemRandom()这是一个愚蠢的问题,但我想知道哪种实现使用起来更安全(有适当的解释)?为什么?使用它比其他人有什么优势?Note:AFAIK,random.SystemRandom()usesos.urandom(x).Socomparisonismainlybetweenuuidandrandom.SystemRandom().这是我到目前为止尝试过的:1)importrandomtemp=rand

python - Python 3 的 random.SystemRandom.randint 有错误,还是我使用不正确?

>>>importrandom>>>random.SystemRandom.randint(0,10)Traceback(mostrecentcalllast):File"",line1,inrandom.SystemRandom.randint(0,10)TypeError:randint()missing1requiredpositionalargument:'b'尽管os.urandom,SystemRandom应该给出随机数,randint的工作方式与普通randrange相同:>>>print(random.SystemRandom.randint.__doc__)Retur