Question: Cracking the Password Generator API with Asynchronous - Multi Thread - Multi Process Programming. I want you to make a password cracker. You get the

Cracking the Password Generator API with
Asynchronous - Multi Thread - Multi Process Programming.
I want you to make a password cracker. You get the md5 encrypted text with a Get request and send your guess with a Post request. Your project will be evaluated on the following elements on a base score of 20 points:
Asynchronous programming (40 points)
Multithread / Multiprocess and synchronization elements (40 points)
API code is below:
from flask import Flask, request, jsonify
import hashlib
import random
import string
import json
app = Flask(_name_)
def generate_password():
password ="".join(
random.choices(string.ascii_letters + string.digits, k=random.randint(8,16))
)
return hashlib.md5(password.encode()).hexdigest()
@app.route("/get_password", methods=["GET"])
def get_password():
password = generate_password()
response = jsonify({"password": password})
with open("password.json", "w") as f:
json.dump({"password": password}, f)
return response
@app.route("/check_password", methods=["POST"])
def check_password():
data = request.get_json()
password = data.get("password")
password_hash = hashlib.md5(password.encode()).hexdigest()
with open("password.json", "r") as f:
stored_password = json.load(f).get("password")
if password_hash == stored_password:
return jsonify({"message": "Success"})
else:
return jsonify({"message": "Failed"})
if _name_=="_main_":
app.run()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!