Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to retrieve password in django

Tags:

django

How do we retrieve a password of an user?

u = User.objects.get(username__exact=username) print u.password 

displays sha1$f0971$441cac8f604d49869e33ca125a76253a02fef64e

Is there a function to find the password from this encoded string?

like image 594
John Avatar asked May 16 '12 15:05

John


People also ask

How can I get Django password?

You will need to reset that users password. Try using the set_password(raw_password) method to give the user a new password. Remember to call the save() method to ensure you save the change to the database.

Can we decrypt Django password?

@anotheruser Yes, you can't 'decrypt' a hashed password through django. (A hash is a one-way function not really encryption). You could possibly save the password of the user in plaintext in the DB, when they create a user account.

How do I reset Django password and username?

Create a new superuser with the command "python manage.py createsuperuser". Login as the new super user. Click on the 'users' link. Then click on the user you want to delete.

How does Django hash passwords?

By default, Django uses the PBKDF2 algorithm with a SHA256 hash, a password stretching mechanism recommended by NIST. This should be sufficient for most users: it's quite secure, requiring massive amounts of computing time to break.


2 Answers

No. It's impossible, by design. But there should never be a need to do it anyway.

like image 129
Daniel Roseman Avatar answered Sep 20 '22 15:09

Daniel Roseman


Due to security restrictions the password hash method is one way. You will need to reset that users password.

Try using the set_password(raw_password) method to give the user a new password. Remember to call the save() method to ensure you save the change to the database.

u = User.objects.get(username__exact=username) u.set_password(raw_password) u.save() 
like image 22
Kristian Roebuck Avatar answered Sep 19 '22 15:09

Kristian Roebuck