I have used Django and handled password with make_password and check_password.
however, I get to change a framework to fastapi.
With fastapi, I need to verify passwords that are created by Django because I should use the same database with the data.
How can I handle the passwords in the way that is compatible with Django?
Password's format stored in database is like that 'pbkdf2_sha256$100000$Dl6Atsc1xX0A$0QFvZLpKdcvcmCNixVCdEA5gJ67yef/gkgaCKTYzoo4='
I have found passlib support Django compatible way.
from django.contrib.auth.hashers import make_password
from passlib.handlers.django import django_pbkdf2_sha256
password = 'testpassword123'
django_hash = make_password(password)
is_verified = django_pbkdf2_sha256.verify(password, django_hash)
if is_verified:
print('Correct!!')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With