diff options
Diffstat (limited to 'wsgitools')
-rwxr-xr-x | wsgitools/digest.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/wsgitools/digest.py b/wsgitools/digest.py index c666460..d99f67d 100755 --- a/wsgitools/digest.py +++ b/wsgitools/digest.py @@ -7,14 +7,18 @@ try: from hashlib import md5 except ImportError: from md5 import md5 - +import binascii +import base64 import time sysrand = random.SystemRandom() def gen_rand_str(bytes=33): - return (("%%0%dX" % (2*bytes)) % sysrand.getrandbits(bytes*8) - ).decode("hex").encode("base64").strip() + randnum = sysrand.getrandbits(bytes*8) + randstr = ("%%0%dX" % (2*bytes)) % randnum + randstr = binascii.unhexlify(randstr) + randstr = base64.encodestring(randstr).strip() + return randstr def parse_digest_response(data, ret=dict()): """internal |