Skip to content

Commit

Permalink
Merge pull request #6 from snordhausen/master
Browse files Browse the repository at this point in the history
Use os.urandom() to read from /dev/urandom
  • Loading branch information
tseaver committed Aug 30, 2013
2 parents 1997818 + ab7dcf4 commit 47cbb8d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ZEO/auth/auth_digest.py
Expand Up @@ -46,11 +46,9 @@
from ZEO.hash import sha1

def get_random_bytes(n=8):
if os.path.exists("/dev/urandom"):
f = open("/dev/urandom", 'rb')
b = f.read(n)
f.close()
else:
try:
b = os.urandom(n)
except NotImplementedError:
L = [chr(random.randint(0, 255)) for i in range(n)]
b = b"".join(L)
return b
Expand Down

0 comments on commit 47cbb8d

Please sign in to comment.