コード例 #1
0
def login():
    captcha_check = True
    if request.method == 'POST':
        if 'captcha' in session and 'captcha' in request.form:
            #APP.logger.debug(session['captcha'])
            #APP.logger.debug(md5((request.form['captcha']+secert_key_captcha).encode('utf-8')).hexdigest())
            if session['captcha'] != md5(
                (request.form['captcha'] +
                 secert_key_captcha).encode('utf-8')).hexdigest():
                captcha_check = False

        if captcha_check:
            user = check_user(request.form['username'],
                              request.form['password'])
            if user:
                if user.is_authenticated:
                    flash({
                        'type': 'success',
                        'message': '{} logged in'.format(user.username)
                    })
                    return redirect(url_for('home'))
        flash({
            'type': 'danger',
            'message': 'Username and/or password is incorrect'
        })

    if 'captcha' in session:
        session.pop('captcha')
    random_text = ''.join(choice(ascii_letters.upper()) for x in range(6))
    session['captcha'] = md5(
        (random_text + secert_key_captcha).encode('utf-8')).hexdigest()
    img = gen_image(random_text)

    return render_template('index.html', content='login', captcha=img)
コード例 #2
0
    def generate_dict(self):  
        """
            load_data - Read csv file with the linear dataset 
            - input_string : name of the csv file to read
            - return array with the data loaded
        """
        ascci_ = ascii_letters.upper()
        sudoku_board = np.zeros((9,9), dtype=object)
        sudoku = dict()
        counter = 1 # Columns manage
        letters = 0 # Rows manage

        for value in self.sudoku_input:
            posicion_string = "".join(ascci_[letters] + str(counter))
            variable_ = variable(value, ascci_[letters], counter)
            # Add value to the dictionary
            sudoku.update({posicion_string: variable_})
            # Create board
            sudoku_board[letters][counter - 1] = posicion_string
            # update control variables
            if counter == 9:
                counter = 0
                letters += 1
            counter += 1
        #print(sudoku_board[:,:,0])
        return sudoku, sudoku_board
コード例 #3
0
ファイル: windows.py プロジェクト: ikozhukhov/oTTo
 def free_letters(self):
     """
     Return drive letter not current used.
     """
     available = set(ascii_letters.upper())
     for v in self.volumes.values():
         if v['letter']:
             available.discard(v['letter'])
     return list(available)
コード例 #4
0
ファイル: windows.py プロジェクト: mennis/oTTo
 def free_letters(self):
     """
     Return drive letter not current used.
     """
     available = set(ascii_letters.upper())
     for v in self.volumes.values():
         if v['letter']:
             available.discard(v['letter'])
     return list(available)
コード例 #5
0
def generateTable( key ):
    index = 0
    i = 0

    letters_key = modifyKey( key ) + ascii_letters.upper()

    for letter in letters_key:
        if letter in dict_letters:
            continue
        elif letter == 'J' or letter == 'I':
            dict_letters['I'] = 'I'
            dict_letters['J'] = 'J'
            table[index].append('I')
            i += 1
        else:
            dict_letters[letter] = letter
            table[index].append(letter)
            i += 1
        if i % 5 == 0:
            table.append([])
            index += 1
コード例 #6
0
ファイル: routes.py プロジェクト: heknt/dbisworkshops
def generate_url_id():
    alphabet = digits + ascii_letters.upper() + ascii_letters
    url_id = ''.join(sec_choice(alphabet) for i in range(10))
    return url_id
コード例 #7
0
ファイル: 20181216_pagerank.py プロジェクト: koffer9/NLP
def generate_name(): return ''.join([random.choice(ascii_letters.upper()) for _ in range(3)])
print(generate_name())
コード例 #8
0
import hashlib
from string import ascii_letters

uppers = ascii_letters.upper()[:26]
nums = ''.join([str(x) for x in range(10)])
hexChar = nums + 'ABCDEF'

h = input('Enter suspected hash:').upper()
if len(h) != 32:
    raise (Exception('Not a 32 char hex string'))
if not all([x in hexChar for x in h]):
    raise (Exception('Not a hex string'))

salts = input('Enter comma separated list of possible salts:').split(',')
r = int(input('Enter possible range upper limit int: '))


def iterator(h, salt, rng, enc='UTF-8'):
    found = 0
    for i in range(rng):
        temp = hashlib.md5(bytes(salt, enc) + bytes(i)).hexdigest().upper()
        #print(temp,'\t',h)
        if temp == h:
            print('-- Match found --', '\n', 'md5:', salt, enc, i)
            found = 1
            break
    if found == 0:
        print('Nothing found, try increasing the range or  number of salts')


saltList = salts + ['/'.join(salts)] + ['.'.join(salts)] + ['']