import sqlite3 from Forms._datasources import * from Manager._User import User from conf import load_in from cryptography.fernet import Fernet, MultiFernet from flask import session, render_template, redirect settings = load_in() def _datasources(request): form = TwitterForm(request.form) if request.method == 'POST' and form.validate(): m1 = form.access_token.data m2 = form.access_token_secret.data m3 = form.consumer_key.data m4 = form.consumer_secret.data my_list = [ bytes(m1, 'utf-8'), bytes(m2, 'utf-8'), bytes(m3, 'utf-8'), bytes(m4, 'utf-8') ] first = Fernet.generate_key() second = Fernet.generate_key() key1 = Fernet(first) key2 = Fernet(second) x = MultiFernet([key1, key2]) token1 = x.encrypt(my_list[0]) token2 = x.encrypt(my_list[1]) token3 = x.encrypt(my_list[2])
def go(Admin, Password): file = open('CONFIG.txt', 'a') file.close() from conf import Config manager = Config() manager.setup_main_db() manager.set_users_db() from conf import load_in settings = load_in() conn = sqlite3.connect(settings['MAIN_DB']) conn.execute("CREATE TABLE IF NOT EXISTS {tn} (id INTEGER," "email TEXT," "email_verified INTEGER," "username TEXT," "password TEXT," "data_tables TEXT," "logged_in INTEGER, " "subscribed INTEGER," "charts TEXT," "models TEXT," "groups TEXT," "first_name TEXT," "last_name TEXT," "friends TEXT," "active INTEGER," "reset_request INTEGER," "data_sources TEXT," "projects TEXT," "is_authenticated INTEGER," "PRIMARY KEY (username))".format(tn='users')) conn.commit() conn.execute("""INSERT INTO users VALUES ('{id}', '{email}', '{email_verified}', '{username}', '{password}', '{data_tables}', {logged_in}, {subscribed}, '{charts}', '{models}', '{groups}', '{first_name}', '{last_name}', '{friends}', {active}, {reset_request}, '{data_sources}', '{projects}', {is_authenticated})""".format( id=1, email='*****@*****.**', email_verified=1, username=Admin, password=make_password(Password), data_tables='', logged_in=1, subscribed=0, charts="", models="", groups="", first_name="", last_name="", friends="", active=1, reset_request=0, data_sources="", projects="", is_authenticated=0)) conn.commit() conn.close() from Manager._FileController import FileController FileController().file_handler(Admin)