Django built-in User class provides user password storage, validation, modification and other functions, can be very convenient for you to provide password services to users.
By default, Ddjango uses pbkdf2_sha256 to store and manage passwords, which can of course be customized.
Django selects which algorithms to use with the PASSWORD_HASHERS setting.
Here's a list of the classes of hashing algorithms supported by Django. The first element of the list (i.e. settings.PASSWORD_HASHERS[0]) will be used to store the password, all the other elements are hashes used for authentication and they can be used to check existing passwords. The idea is that if you plan to use a different algorithm, you need to modify PASSWORD_HASHERS to put your favorite algorithm first in the list.
Password_hashers in a settings looks like this:
PASSWORD_HASHERS = ( '.PBKDF2PasswordHasher', '.PBKDF2SHA1PasswordHasher', '.BCryptSHA256PasswordHasher', '', '.SHA1PasswordHasher', '.MD5PasswordHasher', '', )
Specifically in Django in the user password generation, verification process is how, through the module in a few functions to understand the general. Through the understanding of the two functions , you can completely separate from the built-in User, the realization of a custom user table using django built-in password mechanism.
first import (data)
from import make_password, check_password
As you can see by the function names, there are two main functions, creating passwords and verifying them.
usage
ps = "123456"
dj_ps = make_password(ps, None, 'pbkdf2_sha256') #create a django password, the second parameter is None which means that the password is not used every time it is generated, the third parameter is the algorithm, and the last two parameters can be ignored.
ps_bool = check_password(ps, dj_ps) # check_password The return value is aBooltypology,Verify the correctness of the password
Above this Django comes with encryption algorithms and encryption modules in detail is all that I have shared with you, I hope to be able to give you a reference, and I hope you will support me more.