

def generateCNONCE(): """http://www.faqs.org/rfcs/rfc2831.html requires at least 64bits of entropy for the cnonce.""" # Each character [A-Za-z0-9] character has ~5.95 bits # (log(2) 62) of entropy and so we need a string of at # least 11 characters to have 64bits of entropy. We're # using 128bits of entropy. cnonceLength = 22 cnonceList = [None] * cnonceLength for i in xrange(cnonceLength): randValue = random.randint(0,61) if randValue < 26: cnonceList[i] = chr(ord('A') + randValue) elif randValue < 52: cnonceList[i] = chr(ord('a') + randValue - 26) else: cnonceList[i] = chr(ord('0') + randValue - 52) return "".join(cnonceList)
This site is licensed under a
Creative Commons License