From f46474c3e2dde513cb6e9a365c368172336a58cf Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Sat, 8 Dec 2007 20:07:57 -0800 Subject: [PATCH] Switch from the entropy definition to using os.urandom. --- khash.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/khash.py b/khash.py index 8a5bc61..1832edf 100644 --- a/khash.py +++ b/khash.py @@ -2,17 +2,7 @@ # see LICENSE.txt for license information from sha import sha -import random - -#this is ugly, hopefully os.entropy will be in 2.4 -try: - from entropy import entropy -except ImportError: - def entropy(n): - s = '' - for i in range(n): - s += chr(random.randint(0,255)) - return s +from os import urandom def intify(hstr): """20 bit hash, big-endian -> long python integer""" @@ -37,7 +27,7 @@ def distance(a, b): def newID(): """returns a new pseudorandom globally unique ID string""" h = sha() - h.update(entropy(20)) + h.update(urandom(20)) return h.digest() def newIDInRange(min, max): -- 2.39.5