def _random_license_long(): from codebay.common import randutil res = 0L m = 262144L for i in xrange(5): res = (res * m) + long(randutil.random_float() * 262144L) return res
def generate_password(length=8): """Generate a random password.""" pw = '' for i in xrange(length): idx = int(randutil.random_float() * float(len(_chars))) if idx >= len(_chars): idex = len(_chars) - 1 # should never happen pw += _chars[idx] if len(pw) != length: raise Exception('internal error in generate_password: length does not match (%d != %d)' % (len(pw), length)) return pw
def generate_password(length=8): """Generate a random password.""" pw = '' for i in xrange(length): idx = int(randutil.random_float() * float(len(_chars))) if idx >= len(_chars): idex = len(_chars) - 1 # should never happen pw += _chars[idx] if len(pw) != length: raise Exception( 'internal error in generate_password: length does not match (%d != %d)' % (len(pw), length)) return pw