def adduser(): if request.method == 'POST': user = request.form['buser'] if LoginSQL.getPass(user) is None: import hashlib import random ans = random.uniform(1, 10) hashpass1 = hashlib.sha1(str(ans).encode()) passd1 = hashpass1.hexdigest() hashpass0 = hashlib.sha256(passd1.replace('\n', '').encode()) ManageSQL.addUser(user, hashpass0.hexdigest(), '0', '1') return passd1 else: return '使用者已經他媽的存在了喔!'
def login(): if request.method == 'POST': user = request.form['buser'] passd = request.form['bpass'] password = LoginSQL.getPass(user) if not password: return '帳號錯誤' else: pathuser = password[0] hashsha = hashlib.sha256(passd.replace('\n', '').encode()) if pathuser == hashsha.hexdigest(): session['username'] = user return redirect(url_for('panel')) else: return '密碼錯誤' else: return '想try我後台?你怎摸不去吃大便'