示例#1
0
文件: ocra.py 项目: choth02/LinOTP
    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)
示例#2
0
文件: ocra.py 项目: rb12345/Elm
    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)
示例#3
0
文件: ocra.py 项目: xmycroftx/LinOTP
    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)
示例#4
0
def randchar():
    import string
    chars = string.letters + string.digits
    return urandom.choice(chars)
示例#5
0
文件: util.py 项目: richarddlmay/Elm
def generate_password(size=6, characters=string.ascii_lowercase + string.ascii_uppercase + string.digits):
    return ''.join(urandom.choice(characters) for x in range(size))
示例#6
0
文件: util.py 项目: xmycroftx/LinOTP
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))
示例#7
0
文件: openid.py 项目: stojmir/LinOTP
def randchar():
    import string
    chars = string.letters + string.digits
    return urandom.choice(chars)
示例#8
0
文件: util.py 项目: syllaibr64/LinOTP
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))