def data2randomChallenge(self, data): ''' build a random challenge according to the challenge definition ''' alphnum = 'abcdefghijklmnopqrstuvwxyz' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + '0123456789' digits = '0123456789' hex = digits + 'abcdef' challenge = '' c_type = self.Q[0] c_len = self.Q[1] if c_type == 'A': for c in range(0, c_len): challenge += urandom.choice(alphnum) elif c_type == 'N': for c in range(0, c_len): challenge += urandom.choice(digits) elif c_type == 'H': for c in range(0, c_len): challenge += urandom.choice(hex) challenge = challenge[:c_len] return unicode(challenge)
def data2randomChallenge(self, data): """ build a random challenge according to the challenge definition """ alphnum = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" digits = "0123456789" hex = digits + "abcdef" challenge = "" c_type = self.Q[0] c_len = self.Q[1] if c_type == "A": for c in range(0, c_len): challenge += urandom.choice(alphnum) elif c_type == "N": for c in range(0, c_len): challenge += urandom.choice(digits) elif c_type == "H": for c in range(0, c_len): challenge += urandom.choice(hex) challenge = challenge[:c_len] return unicode(challenge)
def randchar(): import string chars = string.letters + string.digits return urandom.choice(chars)
def generate_password(size=6, characters=string.ascii_lowercase + string.ascii_uppercase + string.digits): return ''.join(urandom.choice(characters) for x in range(size))
def generate_password(size=6, characters=None): if not characters: characters = string.ascii_lowercase + string.ascii_uppercase + string.digits return ''.join(urandom.choice(characters) for _x in range(size))
def generate_password(size=6, characters=None): if not characters: characters = string.ascii_lowercase + \ string.ascii_uppercase + string.digits return ''.join(urandom.choice(characters) for _x in range(size))