def keygen(): form = KeyForm() if form.validate_on_submit(): flash('Key Generation Complete', 'success') return render_template('generatekey.html', title='Generate AES Keys', form=form, key=generate_secret_key_for_AES_cipher( int(form.keysize.data))) return render_template('generatekey.html', title='Generate AES Key', form=form)
def login(): if request.method == 'GET' and session.get('logged_in'): return redirect_back('home') form = KeyForm() if request.method == 'POST' and form.validate_on_submit(): key = form.key.data if check_password_hash(Key.get_by_id(1).key, key): session['logged_in'] = True flash('<script>alert("登陆认证成功")</script>') return redirect(url_for('home')) else: flash('<script>alert("密码验证失败")</script>') return render_template('login.html', form=form)