MD5加密接口
from flask import Flask, request, jsonify
{"username": "admin1", "password": "E10ADC3949BA59ABBE56E057F20F883E"},
{"username": "admin2", "password": "C33367701511B4F6020EC61DED352059"}
@app.route("/post_md5",methods=['post'])
username = request.form.get('username')
password = request.form.get('password')
if not username or not password:
return jsonify({'error': '用户名和密码是必填项'})
hash_pwd = hashlib.md5(password.encode()).hexdigest().upper()
if user['username'] == username and user['password'] == hash_pwd:
return jsonify({'message': '登录成功'})
return jsonify({'error': '用户名或密码不正确'})
if __name__ == '__main__':
base64加密接口
{"username": "admin1", "password": "MTIzNDU2"},
{"username": "admin2", "password": "NjU0MzIx"}
@app.route('/post_base64', methods=['POST'])
username = request.json.get('username')
password = request.json.get('password')
if not username or not password:
return jsonify({'error': '用户名和密码是必填项'})
encoded_password = base64.b64encode(password.encode()).decode()
if user['username'] == username and user['password'] == encoded_password:
return jsonify({'message': '登录成功'})
return jsonify({'error': '用户名或密码不正确'})
if __name__ == '__main__':