Solution 1 :

Found the solution to my own problem:

I made the form method POST and I added a name in the input box. I named it “testing123”:

<form method = "POST">
    {% csrf_token %}
    <h1 style="display:inline; color: #4CAF50">Password</h1>
    <input type="password" name = "testing123" name="Password" style="display:inline;">
    <input style="position: absolute;left: 50%;display:block;" type="submit" value="Submit">
</form>

Thus, when the user clicks submit, it is seen as a POST request. The view can be configured to take in the POST request (if request.method ==”POST”):

def view(request, pk):
    if request.method =="POST":
        epic = request.POST.get("testing123")
        return HttpResponse(epic)

    else:
        location = Location.objects.get(id=pk)
    
    context = {
        'location': location
    }

    return render(request, "main/detail_view.html", context)

As seen above, I used request.POST.get(“testing123”) to get the information the user inputted in the input box (recall that the input box was called “testing123” ). I stored that information into a variable, named “epic”, and returned that information as an Http Response. Thus, since the information can be captured in a variable and in string form, I can alter it all I want and it can be used to decrypt the user’s passwords.

Problem :

I am currently trying to make a password manager with Django. The code for it can be found here, and the version of the code I’m referencing is when commit id “39dd9110a8aa098399af0511a963e447a0d45afb” was pushed to GitHub. All code referenced will be in the django app titled “main”.

The home page looks like this: 2

This is what the page in question looks like: 3
(In the project, this page is displayed after clicking the text “GitHub”)

In the input area, the user provides their master password, and then clicks the submit button. I would like to retrieve that password and alter it(I will use it to decrypt their other passwords, but I do not need help decrypting, I need help altering it). And after altering it, I would like to display the altered text on the page.

In the file named “detailed_view.html”, the code containing the input field is wrapped in form tags.

Code:

<form method = "POST">
    {% csrf_token %}
    <h1 style="display:inline; color: #4CAF50">Password</h1>
    <input type="password" name="Password" style="display:inline;">
    <input style="position: absolute;left: 50%;display:block;" type="submit" value="Submit">
</form>

After the user clicks “submit”, the information is brought to the view() function in views.py (line 64):

@login_required
def view(request, pk):
    if request.method =="POST":
        return HttpResponse(request)

    location = Location.objects.get(id=pk)
    context = {
        'location': location
    }

    return render(request, "main/detail_view.html", context)

After which, the user is directed to a page where it displays the CSRF Middleware Token with the password they inputted.

Ex: if the user inputted the text “password123”, it will display something like this: “csrfmiddlewaretoken=nfQ3bn6d2Cxa7sFJXyIInaHaFkq6T5BkaXn2RCvrSRNVq4HNmakkh6OeGWELkKf&Password=password123”.
I would like to retrieve the last part (“password123”) to use it to decrypt.

Extra: Is there a way to retieve it without being prone to SQL injections?

By