我想检查我为名为'user'的用户存储在数据库中的密码是什么。如何找到存储在django.contrib.auth.models.User中的密码
这是我所做的。
[email protected]:~/Documents/Django/django_bookmarks$ python manage.py shell
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.contrib.auth.models import User
>>> user = User.objects.get(id=1)
>>> user.username, user.password
(u'user', u'sha1$6934a$f92c73726c0bd5d4821013ad4161578a2114090f')
>>>
>>> import hashlib
>>> hexhash = hashlib.sha1("password")
>>> hexhash
<sha1 HASH object @ 0x99c18c0>
>>> hexhash.digest
<built-in method digest of _hashlib.HASH object at 0x99c18c0>
我记得我已经使用'密码'作为用户的密码,但我无法验证它。
问题>如何找出用户的密码是什么?
谢谢